All files / languages language-client-factory.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68                                                                                                                                       
import * as vscode from 'vscode';
 
/**
 * Options passed to the language client factory for creating a platform-specific language client.
 */
export interface LanguageClientFactoryOptions {
	/**
	 * Unique identifier for the language client channel.
	 */
	channelId: string;
 
	/**
	 * Human-readable name of the language.
	 */
	languageName: string;
 
	/**
	 * Relative path to the compiled language server module (e.g. `dist/turtle-language-server.js`).
	 */
	serverPath: string;
 
	/**
	 * The language ID for document selectors.
	 */
	languageId: string;
 
	/**
	 * The output channel for logging.
	 */
	outputChannel: vscode.OutputChannel;
}
 
/**
 * A minimal interface for language clients that is compatible with both
 * `vscode-languageclient/browser` and `vscode-languageclient/node` implementations.
 */
export interface ILanguageClient {
	/**
	 * Start the language client and establish a connection to the language server.
	 */
	start(): Promise<void>;
 
	/**
	 * Stop the language client and clean up resources. After stopping, the client should not be restarted.
	 */
	stop(): Promise<void> | void;
 
	/**
	 * Register a handler for notifications from the language server. The method should return a disposable that can be used to unregister the handler.
	 * @param method The name of the notification method to handle.
	 * @param handler The function to handle incoming notifications for the specified method.
	 * @returns A disposable that can be used to unregister the handler.
	 * @remarks The handler will be called with the parameters sent by the language server for the specified method.
	 * The exact types of the parameters depend on the language server's implementation and are not specified in this interface.
	 */
	onNotification(method: string, handler: (...params: any[]) => any): vscode.Disposable;
}
 
/**
 * Factory function type for creating platform-specific language clients.
 * Browser implementations use Web Workers; Node.js implementations use IPC transport.
 * @param context The extension context for registering disposables.
 * @param options The options for configuring the language client.
 * @returns An instance of ILanguageClient that can be started and stopped.
 * @remarks The factory should create but not start the language client. The caller will call `start()` on the returned client when ready.
 */
export type LanguageClientFactory = (context: vscode.ExtensionContext, options: LanguageClientFactoryOptions) => ILanguageClient;