Skip to content

Commit 139c455

Browse files
committed
Use Disposable type instead of isDisposable function
1 parent b53b33e commit 139c455

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

extensions/ql-vscode/src/common/disposable-object.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,3 @@ export class DisposableObject implements Disposable {
8888
}
8989
}
9090
}
91-
92-
export function isDisposable(obj: unknown): obj is Disposable {
93-
return obj !== undefined && typeof (obj as Disposable).dispose === "function";
94-
}

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { redactableError } from "../common/errors";
2525
import type { LocalQueries } from "./local-queries";
2626
import { tryGetQueryMetadata } from "../codeql-cli/query-metadata";
2727
import { telemetryListener } from "../common/vscode/telemetry";
28-
import { isDisposable } from "../common/disposable-object";
28+
import type { Disposable } from "../common/disposable-object";
2929

3030
function formatResultMessage(result: CoreQueryResults): string {
3131
switch (result.resultType) {
@@ -66,7 +66,7 @@ export class LocalQueryRun {
6666
* The logger is only available while the query is running and will be disposed of when the
6767
* query completes.
6868
*/
69-
public readonly logger: Logger, // Public so that other clients, like the debug adapter, know where to send log output
69+
public readonly logger: Logger & Disposable, // Public so that other clients, like the debug adapter, know where to send log output
7070
private readonly queryHistoryManager: QueryHistoryManager,
7171
private readonly cliServer: CodeQLCliServer,
7272
) {}
@@ -98,9 +98,7 @@ export class LocalQueryRun {
9898
// display and sorting might depend on the number of results
9999
await this.queryHistoryManager.refreshTreeView();
100100

101-
if (isDisposable(this.logger)) {
102-
this.logger.dispose();
103-
}
101+
this.logger.dispose();
104102
}
105103

106104
/**
@@ -120,9 +118,7 @@ export class LocalQueryRun {
120118
this.queryInfo.failureReason = err.message;
121119
await this.queryHistoryManager.refreshTreeView();
122120

123-
if (isDisposable(this.logger)) {
124-
this.logger.dispose();
125-
}
121+
this.logger.dispose();
126122
}
127123

128124
/**

0 commit comments

Comments
 (0)