@eclipse-glsp/theia-integration
Version:
Glue code to integrate GLSP clients into Eclipse Theia
101 lines • 5.27 kB
TypeScript
/********************************************************************************
* Copyright (c) 2017-2026 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 { MaybePromise } from '@eclipse-glsp/protocol';
import { Channel, Disposable, DisposableCollection } from '@theia/core';
import { ProcessErrorEvent } from '@theia/process/lib/node/process';
import { ProcessManager } from '@theia/process/lib/node/process-manager';
import { RawProcess, RawProcessFactory } from '@theia/process/lib/node/raw-process';
import * as cp from 'child_process';
import { GLSPContribution } from '../common';
export declare const GLSPServerContribution: unique symbol;
/**
* The backend service component of a {@link GLSPContribution}. Responsible for launching new
* GLSP server processes or connecting to a running server instance.
*/
export interface GLSPServerContribution extends GLSPContribution, Disposable {
/**
* Establish a connection between the given client (connection) and the GLSP server.
* @param clientChannel The client (channel) which should be connected to the server
* @returns A 'Disposable' that cleans up all client (channel)-specific resources.
*/
connect(clientChannel: Channel): MaybePromise<Disposable>;
/**
* Optional function that can be used by the contribution to launch an embedded GLSP server.
* @returns A 'Promise' that resolves after the server has been successfully launched and is ready to establish a client connection.
*/
launch?(): Promise<Disposable>;
/**
* The {@link GLSPServerContributionOptions} for this contribution.
*/
options: GLSPServerContributionOptions;
}
/**
* Configuration options for a {@link GLSPServerContribution}.
*/
export interface GLSPServerContributionOptions {
/** Declares wether the server should be launched on application start or on demand (e.g. on widget open). */
launchOnDemand: boolean;
/**
* Declares that the server contribution does not have to launch a server but expects it to be already started.
* Mostly used for debugging purposes during development.
*/
launchedExternally: boolean;
}
export declare namespace GLSPServerContributionOptions {
/** Default values for {@link GLSPServerContributionOptions } **/
function createDefaultOptions(): GLSPServerContributionOptions;
/**
* Utility function to partially set the launch options. Default values (from 'defaultOptions') are used for
* options that are not specified.
* @param options (partial) launch options that should be extended with default values (if necessary).
*/
function configure(options?: Partial<GLSPServerContributionOptions>): GLSPServerContributionOptions;
const debugArgument = "--glspDebug";
/**
* Utility function which specifies if the Theia application has been started in debug mode.
* i.e. if the '--glspDebug' flag has been passed.
* @returns `true` if the '--glspDebug' flag has been set.
*/
function inDebugMode(): boolean;
/**
* Utility function that processes the contribution launch options to determine wether the server should be launched on
* application start.
* @param contribution The glsp server contribution.
* @returns `true` if the server should be launched on application start.
*/
function shouldLaunchOnApplicationStart(contribution: GLSPServerContribution): boolean;
}
/**
* A base implementation of {@link GLSPServerContribution} that provides utility methods for forwarding
* (frontend) client connections to a GLSP server and for spawning new server processes.
*/
export declare abstract class BaseGLSPServerContribution implements GLSPServerContribution {
protected readonly processFactory: RawProcessFactory;
protected readonly processManager: ProcessManager;
abstract readonly id: string;
options: GLSPServerContributionOptions;
protected toDispose: DisposableCollection;
protected initialize(): void;
connect(clientChannel: Channel): Promise<Disposable>;
abstract doConnect(clientChannel: Channel): MaybePromise<Disposable>;
abstract createContributionOptions?(): Partial<GLSPServerContributionOptions>;
protected spawnProcessAsync(command: string, args?: string[], options?: cp.SpawnOptions): Promise<RawProcess>;
protected onDidFailSpawnProcess(error: Error | ProcessErrorEvent): void;
protected processLogError(line: string): void;
protected processLogInfo(line: string): void;
dispose(): void;
}
//# sourceMappingURL=glsp-server-contribution.d.ts.map