Skip to content

Commit 23173bf

Browse files
Merge pull request #2525 from github/robertbrignull/sendRequest_progress
Remove ProgressCallback / CancellationToken arguments where they aren't used
2 parents c40be89 + 3685575 commit 23173bf

File tree

19 files changed

+93
-341
lines changed

19 files changed

+93
-341
lines changed

extensions/ql-vscode/src/data-extensions-editor/data-extensions-editor-view.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,6 @@ export class DataExtensionsEditorView extends AbstractWebview<
300300
this.app.workspaceStoragePath ?? this.app.globalStoragePath,
301301
this.app.credentials,
302302
(update) => this.showProgress(update),
303-
tokenSource.token,
304303
this.cliServer,
305304
);
306305
if (!database) {
@@ -354,16 +353,12 @@ export class DataExtensionsEditorView extends AbstractWebview<
354353

355354
// After the flow model has been generated, we can remove the temporary database
356355
// which we used for generating the flow model.
357-
await this.databaseManager.removeDatabaseItem(
358-
() =>
359-
this.showProgress({
360-
step: 3900,
361-
maxStep: 4000,
362-
message: "Removing temporary database",
363-
}),
364-
tokenSource.token,
365-
database,
366-
);
356+
await this.showProgress({
357+
step: 3900,
358+
maxStep: 4000,
359+
message: "Removing temporary database",
360+
});
361+
await this.databaseManager.removeDatabaseItem(database);
367362

368363
await this.clearProgress();
369364
}

extensions/ql-vscode/src/databases/database-fetcher.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fetch, { Response } from "node-fetch";
22
import { zip } from "zip-a-folder";
33
import { Open } from "unzipper";
4-
import { Uri, CancellationToken, window, InputBoxOptions } from "vscode";
4+
import { Uri, window, InputBoxOptions } from "vscode";
55
import { CodeQLCliServer } from "../codeql-cli/cli";
66
import {
77
ensureDir,
@@ -44,7 +44,6 @@ export async function promptImportInternetDatabase(
4444
databaseManager: DatabaseManager,
4545
storagePath: string,
4646
progress: ProgressCallback,
47-
token: CancellationToken,
4847
cli?: CodeQLCliServer,
4948
): Promise<DatabaseItem | undefined> {
5049
const databaseUrl = await window.showInputBox({
@@ -63,7 +62,6 @@ export async function promptImportInternetDatabase(
6362
storagePath,
6463
undefined,
6564
progress,
66-
token,
6765
cli,
6866
);
6967

@@ -86,7 +84,6 @@ export async function promptImportInternetDatabase(
8684
* @param storagePath where to store the unzipped database.
8785
* @param credentials the credentials to use to authenticate with GitHub
8886
* @param progress the progress callback
89-
* @param token the cancellation token
9087
* @param cli the CodeQL CLI server
9188
*/
9289
export async function promptImportGithubDatabase(
@@ -95,7 +92,6 @@ export async function promptImportGithubDatabase(
9592
storagePath: string,
9693
credentials: Credentials | undefined,
9794
progress: ProgressCallback,
98-
token: CancellationToken,
9995
cli?: CodeQLCliServer,
10096
): Promise<DatabaseItem | undefined> {
10197
const githubRepo = await askForGitHubRepo(progress);
@@ -109,7 +105,6 @@ export async function promptImportGithubDatabase(
109105
storagePath,
110106
credentials,
111107
progress,
112-
token,
113108
cli,
114109
);
115110

@@ -157,7 +152,6 @@ export async function askForGitHubRepo(
157152
* @param storagePath where to store the unzipped database.
158153
* @param credentials the credentials to use to authenticate with GitHub
159154
* @param progress the progress callback
160-
* @param token the cancellation token
161155
* @param cli the CodeQL CLI server
162156
* @param language the language to download. If undefined, the user will be prompted to choose a language.
163157
**/
@@ -167,7 +161,6 @@ export async function downloadGitHubDatabase(
167161
storagePath: string,
168162
credentials: Credentials | undefined,
169163
progress: ProgressCallback,
170-
token: CancellationToken,
171164
cli?: CodeQLCliServer,
172165
language?: string,
173166
): Promise<DatabaseItem | undefined> {
@@ -213,7 +206,6 @@ export async function downloadGitHubDatabase(
213206
storagePath,
214207
`${owner}/${name}`,
215208
progress,
216-
token,
217209
cli,
218210
);
219211
}
@@ -231,7 +223,6 @@ export async function importArchiveDatabase(
231223
databaseManager: DatabaseManager,
232224
storagePath: string,
233225
progress: ProgressCallback,
234-
token: CancellationToken,
235226
cli?: CodeQLCliServer,
236227
): Promise<DatabaseItem | undefined> {
237228
try {
@@ -242,7 +233,6 @@ export async function importArchiveDatabase(
242233
storagePath,
243234
undefined,
244235
progress,
245-
token,
246236
cli,
247237
);
248238
if (item) {
@@ -275,7 +265,6 @@ export async function importArchiveDatabase(
275265
* @param storagePath where to store the unzipped database.
276266
* @param nameOverride a name for the database that overrides the default
277267
* @param progress callback to send progress messages to
278-
* @param token cancellation token
279268
*/
280269
async function databaseArchiveFetcher(
281270
databaseUrl: string,
@@ -284,7 +273,6 @@ async function databaseArchiveFetcher(
284273
storagePath: string,
285274
nameOverride: string | undefined,
286275
progress: ProgressCallback,
287-
token: CancellationToken,
288276
cli?: CodeQLCliServer,
289277
): Promise<DatabaseItem> {
290278
progress({
@@ -327,8 +315,6 @@ async function databaseArchiveFetcher(
327315
const makeSelected = true;
328316

329317
const item = await databaseManager.openDatabase(
330-
progress,
331-
token,
332318
Uri.file(dbPath),
333319
makeSelected,
334320
nameOverride,

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

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ export class DatabaseUI extends DisposableObject {
314314

315315
private async handleSetDefaultTourDatabase(): Promise<void> {
316316
return withProgress(
317-
async (progress, token) => {
317+
async () => {
318318
try {
319319
if (!workspace.workspaceFolders?.length) {
320320
throw new Error("No workspace folder is open.");
@@ -332,8 +332,6 @@ export class DatabaseUI extends DisposableObject {
332332
const isTutorialDatabase = true;
333333

334334
await this.databaseManager.openDatabase(
335-
progress,
336-
token,
337335
uri,
338336
makeSelected,
339337
nameOverride,
@@ -485,13 +483,12 @@ export class DatabaseUI extends DisposableObject {
485483

486484
private async handleChooseDatabaseInternet(): Promise<void> {
487485
return withProgress(
488-
async (progress, token) => {
486+
async (progress) => {
489487
await promptImportInternetDatabase(
490488
this.app.commands,
491489
this.databaseManager,
492490
this.storagePath,
493491
progress,
494-
token,
495492
this.queryServer?.cliServer,
496493
);
497494
},
@@ -503,7 +500,7 @@ export class DatabaseUI extends DisposableObject {
503500

504501
private async handleChooseDatabaseGithub(): Promise<void> {
505502
return withProgress(
506-
async (progress, token) => {
503+
async (progress) => {
507504
const credentials = isCanary() ? this.app.credentials : undefined;
508505

509506
await promptImportGithubDatabase(
@@ -512,7 +509,6 @@ export class DatabaseUI extends DisposableObject {
512509
this.storagePath,
513510
credentials,
514511
progress,
515-
token,
516512
this.queryServer?.cliServer,
517513
);
518514
},
@@ -608,14 +604,13 @@ export class DatabaseUI extends DisposableObject {
608604

609605
private async handleClearCache(): Promise<void> {
610606
return withProgress(
611-
async (progress, token) => {
607+
async (_progress, token) => {
612608
if (
613609
this.queryServer !== undefined &&
614610
this.databaseManager.currentDatabaseItem !== undefined
615611
) {
616612
await this.queryServer.clearCacheInDatabase(
617613
this.databaseManager.currentDatabaseItem,
618-
progress,
619614
token,
620615
);
621616
}
@@ -633,7 +628,7 @@ export class DatabaseUI extends DisposableObject {
633628

634629
private async handleSetCurrentDatabase(uri: Uri): Promise<void> {
635630
return withProgress(
636-
async (progress, token) => {
631+
async (progress) => {
637632
try {
638633
// Assume user has selected an archive if the file has a .zip extension
639634
if (uri.path.endsWith(".zip")) {
@@ -643,11 +638,10 @@ export class DatabaseUI extends DisposableObject {
643638
this.databaseManager,
644639
this.storagePath,
645640
progress,
646-
token,
647641
this.queryServer?.cliServer,
648642
);
649643
} else {
650-
await this.databaseManager.openDatabase(progress, token, uri);
644+
await this.databaseManager.openDatabase(uri);
651645
}
652646
} catch (e) {
653647
// rethrow and let this be handled by default error handling.
@@ -668,10 +662,10 @@ export class DatabaseUI extends DisposableObject {
668662
databaseItems: DatabaseItem[],
669663
): Promise<void> {
670664
return withProgress(
671-
async (progress, token) => {
665+
async () => {
672666
await Promise.all(
673667
databaseItems.map((dbItem) =>
674-
this.databaseManager.removeDatabaseItem(progress, token, dbItem),
668+
this.databaseManager.removeDatabaseItem(dbItem),
675669
),
676670
);
677671
},
@@ -758,15 +752,11 @@ export class DatabaseUI extends DisposableObject {
758752

759753
return await withInheritedProgress(
760754
progress,
761-
async (progress, token) => {
755+
async (progress) => {
762756
if (byFolder) {
763757
const fixedUri = await this.fixDbUri(uri);
764758
// we are selecting a database folder
765-
return await this.databaseManager.openDatabase(
766-
progress,
767-
token,
768-
fixedUri,
769-
);
759+
return await this.databaseManager.openDatabase(fixedUri);
770760
} else {
771761
// we are selecting a database archive. Must unzip into a workspace-controlled area
772762
// before importing.
@@ -776,7 +766,6 @@ export class DatabaseUI extends DisposableObject {
776766
this.databaseManager,
777767
this.storagePath,
778768
progress,
779-
token,
780769
this.queryServer?.cliServer,
781770
);
782771
}

0 commit comments

Comments
 (0)