-
-
Notifications
You must be signed in to change notification settings - Fork 182
/
Copy pathindex.ts
30 lines (24 loc) · 1.19 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* --------------------------------------------------------------------------------------------
* Copyright (c) 2024 TypeFox and others.
* Licensed under the MIT License. See LICENSE in the package root for license information.
* ------------------------------------------------------------------------------------------ */
import { BaseLanguageClient, MessageTransports, LanguageClientOptions } from 'vscode-languageclient/lib/common/client.js';
export interface IConnectionProvider {
get(encoding: string): Promise<MessageTransports>;
}
export type MonacoLanguageClientOptions = {
name: string;
id?: string;
clientOptions: LanguageClientOptions;
connectionProvider: IConnectionProvider;
}
export class MonacoLanguageClient extends BaseLanguageClient {
protected readonly connectionProvider: IConnectionProvider;
constructor({ id, name, clientOptions, connectionProvider }: MonacoLanguageClientOptions) {
super(id ?? name.toLowerCase(), name, clientOptions);
this.connectionProvider = connectionProvider;
}
protected override createMessageTransports(encoding: string): Promise<MessageTransports> {
return this.connectionProvider.get(encoding);
}
}