UNPKG

@eclipse-glsp/theia-integration

Version:

Glue code to integrate GLSP clients into Eclipse Theia

99 lines 5.44 kB
/******************************************************************************** * Copyright (c) 2019-2024 EclipseSource and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. * * This Source Code may also be made available under the following Secondary * Licenses when the conditions for such availability set forth in the Eclipse * Public License v. 2.0 are satisfied: GNU General Public License, version 2 * with the GNU Classpath Exception which is available at * https://www.gnu.org/software/classpath/license.html. * * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 ********************************************************************************/ import { Args, ConnectionProvider, GLSPClient, InitializeParameters, InitializeResult, MaybePromise } from '@eclipse-glsp/client'; import { DisposableCollection, MessageService } from '@theia/core'; import { FrontendApplication } from '@theia/core/lib/browser'; import { ServiceConnectionProvider } from '@theia/core/lib/browser/messaging/service-connection-provider'; import { Deferred } from '@theia/core/lib/common/promise-util'; import { MessageConnection } from 'vscode-jsonrpc'; import '../../css/command-palette.css'; import '../../css/decoration.css'; import '../../css/diagram.css'; import '../../css/features.css'; import '../../css/theia-dialogs.css'; import '../../css/tool-palette.css'; import { GLSPContribution, WebSocketConnectionInfo } from '../common'; export declare const GLSPClientContribution: unique symbol; /** * The frontend service component of a {@link GLSPContribution}. Responsible for providing & initializing the * {@link GLSPClient}. */ export interface GLSPClientContribution extends GLSPContribution { /** * Triggers the setup for the {@link GLSPClient}. * The activation phase consists of the following steps: * - Establish a service connection to the corresponding backend contribution (`GLSPServerContribution`) * - Create a new {@link GLSPClient} on top of the service connection * - Start the client * - Initialize the server * * The {@link GLSPClientContribution.waitForActivation} function can be used to further delay the activation * @param app Theia`s frontend application */ activate(app: FrontendApplication): MaybePromise<void>; /** * Optional function to delay the activation of this client contribution until certain conditions are met * @param app Theia`s frontend application * @returns A promise that resolves once all activation conditions are met. */ waitForActivation?(app: FrontendApplication): Promise<void>; /** * Deactivates the contribution and disposes all underlying resources e.g. the service connection * and the glsp client. * * @param app Theia`s frontend application */ deactivate(app: FrontendApplication): void; /** * Retrieve the activated {@link GLSPClient}. * @returns A promise of the client that resolves after the client has been started & initialized */ readonly glspClient: Promise<GLSPClient>; } export type WebSocketConnectionOptions = string | WebSocketConnectionInfo; /** * Base implementation for {@link GLSPClientContribution}s. The default implementation setups a {@link GLSPClient} that * uses a Theia service connection to communicate with the corresponding `GLSPBackendContribution`. * Subclasses can override the {@link BaseGLSPClientContribution.getWebSocketConnectionOptions} method. If this method * provides websocket options the `GLSPClient` is not routed via service connection to the Theia backend, and instead directly * communicates with a `GLSPServer` via WebSocket. */ export declare abstract class BaseGLSPClientContribution implements GLSPClientContribution { abstract readonly id: string; protected glspClientDeferred: Deferred<GLSPClient>; protected readonly toDispose: DisposableCollection; protected glspClientStartupTimeout: number; protected getWebSocketConnectionOptions(): MaybePromise<WebSocketConnectionOptions | undefined>; protected readonly messageService: MessageService; protected readonly connectionProvider: ServiceConnectionProvider; get glspClient(): Promise<GLSPClient>; waitForActivation?(app: FrontendApplication): Promise<void>; activate(app: FrontendApplication): MaybePromise<void>; deactivate(_app: FrontendApplication): void; protected doActivate(): void; protected activateClient(): Promise<void>; protected createConnection(): Promise<MessageConnection>; protected createWebSocketConnection(opts: WebSocketConnectionOptions): Promise<MessageConnection>; protected getWebsocketAddress(opts: WebSocketConnectionOptions): string; protected createChannelConnection(): Promise<MessageConnection>; protected start(glspClient: GLSPClient): Promise<void>; protected initialize(languageClient: GLSPClient): Promise<InitializeResult>; protected createInitializeParameters(): Promise<InitializeParameters>; protected createInitializeOptions(): MaybePromise<Args | undefined>; protected createGLSPClient(connectionProvider: ConnectionProvider): Promise<GLSPClient>; dispose(): void; } //# sourceMappingURL=glsp-client-contribution.d.ts.map