From bb86c95a21b8fd9ea4dfcb0cc49b2b3223ed8c59 Mon Sep 17 00:00:00 2001 From: BurstingF <36134155+BurstingF@users.noreply.github.com> Date: Mon, 15 Jul 2024 12:00:33 +0200 Subject: [PATCH] Export ExtensionRuntime (or LanguageClient) for other extensions (#483) This change would export the `ExtensionRuntime` object that is created such that other extensions can access it. This would, for example, allow other extensions to depend on this extension and use the `LanguageClient` it creates to send requests without the need to start their own `LanguageClient`. With the current changes other extensions could access the `LanguageClient` like this: ```typescript const client: LanguageClient = vscode.extensions.getExtension('dafny-lang.ide-vscode')?.exports.client; client.sendRequest(...) ``` Note: Perhaps if exporting `ExtensionRuntime` is a bit too broad, only the `LanguageClient` could be exported instead. --- src/extension.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 6c7ac04..787c527 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -14,14 +14,15 @@ import * as PromiseAny from 'promise.any'; const DafnyVersionTimeoutMs = 5_000; let extensionRuntime: ExtensionRuntime | undefined; -export async function activate(context: ExtensionContext): Promise { +export async function activate(context: ExtensionContext): Promise { if(!await checkAndInformAboutInstallation(context)) { - return; + return undefined; } const statusOutput = window.createOutputChannel(ExtensionConstants.ChannelName); context.subscriptions.push(statusOutput); extensionRuntime = new ExtensionRuntime(context, statusOutput); await extensionRuntime.initialize(); + return extensionRuntime; } export async function deactivate(): Promise {