From e74a2e4a159cc49ad57206f342be8a99b46e70f4 Mon Sep 17 00:00:00 2001 From: Koen Vlaswinkel Date: Wed, 22 Mar 2023 15:14:22 +0100 Subject: [PATCH] Remove `UIService` This class seems to have been introduced at some point to reduce the dependency on VS Code from the test UI service. However, none of its methods are being used anymore, and by using typed commands we have already reduced the dependency on VS Code. Therefore, we can simply remove this class. --- extensions/ql-vscode/src/test-ui.ts | 3 +- .../ql-vscode/src/vscode-utils/ui-service.ts | 32 ------------------- 2 files changed, 1 insertion(+), 34 deletions(-) delete mode 100644 extensions/ql-vscode/src/vscode-utils/ui-service.ts diff --git a/extensions/ql-vscode/src/test-ui.ts b/extensions/ql-vscode/src/test-ui.ts index 102053fec..5739d438f 100644 --- a/extensions/ql-vscode/src/test-ui.ts +++ b/extensions/ql-vscode/src/test-ui.ts @@ -14,7 +14,6 @@ import { import { showAndLogWarningMessage } from "./helpers"; import { TestTreeNode } from "./test-tree-node"; import { DisposableObject } from "./pure/disposable-object"; -import { UIService } from "./vscode-utils/ui-service"; import { QLTestAdapter, getExpectedFile, getActualFile } from "./test-adapter"; import { TestUICommands } from "./common/commands"; @@ -42,7 +41,7 @@ class QLTestListener extends DisposableObject { /** * Service that implements all UI and commands for QL tests. */ -export class TestUIService extends UIService implements TestController { +export class TestUIService extends DisposableObject implements TestController { private readonly listeners: Map = new Map(); constructor(private readonly testHub: TestHub) { diff --git a/extensions/ql-vscode/src/vscode-utils/ui-service.ts b/extensions/ql-vscode/src/vscode-utils/ui-service.ts deleted file mode 100644 index c2ffef0c8..000000000 --- a/extensions/ql-vscode/src/vscode-utils/ui-service.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { TreeDataProvider, window } from "vscode"; -import { DisposableObject } from "../pure/disposable-object"; -import { commandRunner } from "../commandRunner"; - -/** - * A VS Code service that interacts with the UI, including handling commands. - */ -export class UIService extends DisposableObject { - protected constructor() { - super(); - } - - /** - * Registers a command handler with Visual Studio Code. - * @param command The ID of the command to register. - * @param callback Callback function to implement the command. - * @remarks The command handler is automatically unregistered when the service is disposed. - */ - protected registerCommand( - command: string, - callback: (...args: any[]) => any, - ): void { - this.push(commandRunner(command, callback.bind(this))); - } - - protected registerTreeDataProvider( - viewId: string, - treeDataProvider: TreeDataProvider, - ): void { - this.push(window.registerTreeDataProvider(viewId, treeDataProvider)); - } -}