From a449d20456bf7d43691ecdcd804346cdad836c39 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 14 Feb 2018 17:18:07 -0800 Subject: [PATCH] Move LanguageServerProcess to lib/server-manager.js --- lib/auto-languageclient.ts | 21 +++------------------ lib/server-manager.ts | 19 ++++++++++++++++++- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/lib/auto-languageclient.ts b/lib/auto-languageclient.ts index d64d7d1..58f3bbe 100644 --- a/lib/auto-languageclient.ts +++ b/lib/auto-languageclient.ts @@ -4,13 +4,13 @@ import * as rpc from 'vscode-jsonrpc'; import * as path from 'path'; import * as atomIde from 'atom-ide'; import * as linter from 'atom-linter'; -import * as stream from 'stream'; import { Socket } from 'net'; -import { EventEmitter } from 'events'; import { ConsoleLogger, NullLogger, Logger } from './logger'; -import { ServerManager, ActiveServer } from './server-manager.js'; +import { LanguageServerProcess, ServerManager, ActiveServer } from './server-manager.js'; import Convert from './convert.js'; +export { LanguageServerProcess }; + import { AutocompleteDidInsert, AutocompleteProvider, @@ -39,21 +39,6 @@ import SignatureHelpAdapter from './adapters/signature-help-adapter'; export type ConnectionType = 'stdio' | 'socket' | 'ipc'; -// Public: Defines the minimum surface area for an object that resembles a -// ChildProcess. This is used so that language packages with alternative -// language server process hosting strategies can return something compatible -// with AutoLanguageClient.startServerProcess. -export interface LanguageServerProcess extends EventEmitter { - stdin: stream.Writable; - stdout: stream.Readable; - stderr: stream.Readable; - pid: number; - - kill(signal?: string): void; - on(event: 'error', listener: (err: Error) => void): this; - on(event: 'exit', listener: (code: number, signal: string) => void): this; -} - // Public: AutoLanguageClient provides a simple way to have all the supported // Atom-IDE services wired up entirely for you by just subclassing it and // implementing startServerProcess/getGrammarScopes/getLanguageName and diff --git a/lib/server-manager.ts b/lib/server-manager.ts index b4088b8..a6ad187 100644 --- a/lib/server-manager.ts +++ b/lib/server-manager.ts @@ -1,20 +1,37 @@ import { Logger } from './logger'; +import { EventEmitter } from 'events'; import LinterPushV2Adapter from './adapters/linter-push-v2-adapter'; import DocumentSyncAdapter from './adapters/document-sync-adapter'; import SignatureHelpAdapter from './adapters/signature-help-adapter'; import * as path from 'path'; +import * as stream from 'stream'; import * as cp from 'child_process'; import * as ls from './languageclient'; import * as atomIde from 'atom-ide'; import Convert from './convert'; import { CompositeDisposable, ProjectFileEvent, TextEditor } from 'atom'; +// Public: Defines the minimum surface area for an object that resembles a +// ChildProcess. This is used so that language packages with alternative +// language server process hosting strategies can return something compatible +// with AutoLanguageClient.startServerProcess. +export interface LanguageServerProcess extends EventEmitter { + stdin: stream.Writable; + stdout: stream.Readable; + stderr: stream.Readable; + pid: number; + + kill(signal?: string): void; + on(event: 'error', listener: (err: Error) => void): this; + on(event: 'exit', listener: (code: number, signal: string) => void): this; +} + // The necessary elements for a server that has started or is starting. export interface ActiveServer { disposable: CompositeDisposable; projectPath: string; - process: cp.ChildProcess; + process: LanguageServerProcess; connection: ls.LanguageClientConnection; capabilities: ls.ServerCapabilities; linterPushV2?: LinterPushV2Adapter;