Extract ITypeScript server interface

This commit is contained in:
Matt Bierner
2019-06-20 15:52:34 -07:00
parent 804a266e0c
commit 7e1f8d4f1d
2 changed files with 21 additions and 4 deletions

View File

@@ -109,7 +109,7 @@ export class TypeScriptServerSpawner {
version: TypeScriptVersion,
configuration: TypeScriptServiceConfiguration,
pluginManager: PluginManager
): TypeScriptServer {
): ITypeScriptServer {
const apiVersion = version.version || API.defaultVersion;
const { args, cancellationPipeName, tsServerLogFile } = this.getTsServerArgs(configuration, version, apiVersion, pluginManager);
@@ -303,7 +303,24 @@ class ChildServerProcess implements ServerProcess {
}
}
export class TypeScriptServer extends Disposable {
export interface ITypeScriptServer {
readonly onEvent: vscode.Event<Proto.Event>;
readonly onExit: vscode.Event<any>;
readonly onError: vscode.Event<any>;
readonly onReaderError: vscode.Event<Error>;
readonly tsServerLogFile: string | undefined;
kill(): void;
executeImpl(command: string, args: any, executeInfo: { isAsync: boolean, token?: vscode.CancellationToken, expectsResult: false, lowPriority?: boolean }): undefined;
executeImpl(command: string, args: any, executeInfo: { isAsync: boolean, token?: vscode.CancellationToken, expectsResult: boolean, lowPriority?: boolean }): Promise<ServerResponse.Response<Proto.Response>>;
executeImpl(command: string, args: any, executeInfo: { isAsync: boolean, token?: vscode.CancellationToken, expectsResult: boolean, lowPriority?: boolean }): Promise<ServerResponse.Response<Proto.Response>> | undefined;
dispose(): void;
}
export class TypeScriptServer extends Disposable implements ITypeScriptServer {
private readonly _reader: Reader<Proto.Response>;
private readonly _requestQueue = new RequestQueue();
private readonly _callbacks = new CallbackMap<Proto.Response>();

View File

@@ -10,7 +10,7 @@ import * as nls from 'vscode-nls';
import BufferSyncSupport from './features/bufferSyncSupport';
import { DiagnosticKind, DiagnosticsManager } from './features/diagnostics';
import * as Proto from './protocol';
import { TypeScriptServer, TypeScriptServerSpawner } from './tsServer/server';
import { ITypeScriptServer, TypeScriptServerSpawner } from './tsServer/server';
import { ITypeScriptServiceClient, ServerResponse } from './typescriptService';
import API from './utils/api';
import { TsServerLogLevel, TypeScriptServiceConfiguration } from './utils/configuration';
@@ -46,7 +46,7 @@ namespace ServerState {
export class Running {
readonly type = Type.Running;
constructor(
public readonly server: TypeScriptServer,
public readonly server: ITypeScriptServer,
/**
* API version obtained from the version picker after checking the corresponding path exists.