Skip to content

Commit

Permalink
Export ExtensionRuntime (or LanguageClient) for other extensions (#483)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
BurstingF authored Jul 15, 2024
1 parent 0dcecca commit bb86c95
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
export async function activate(context: ExtensionContext): Promise<ExtensionRuntime | undefined> {
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<void> {
Expand Down

0 comments on commit bb86c95

Please sign in to comment.