UNPKG

4.08 kBTypeScriptView Raw
1/// <reference types="node" />
2import * as ls from "./languageclient";
3import { ChildProcess } from "child_process";
4import { Logger } from "./logger";
5import { CompositeDisposable, FilesystemChangeEvent, TextEditor } from "atom";
6import { ReportBusyWhile } from "./utils";
7export declare type MinimalLanguageServerProcess = Pick<ChildProcess, "stdin" | "stdout" | "stderr" | "pid" | "kill" | "on">;
8/**
9 * Public: Defines a language server process which is either a ChildProcess, or it is a minimal object that resembles a
10 * ChildProcess. `MinimalLanguageServerProcess` is used so that language packages with alternative language server
11 * process hosting strategies can return something compatible with `AutoLanguageClient.startServerProcess`.
12 */
13export declare type LanguageServerProcess = ChildProcess | MinimalLanguageServerProcess;
14/** The necessary elements for a server that has started or is starting. */
15export interface ActiveServer {
16 disposable: CompositeDisposable;
17 projectPath: string;
18 process: LanguageServerProcess;
19 connection: ls.LanguageClientConnection;
20 capabilities: ls.ServerCapabilities;
21 /** Out of project directories that this server can also support. */
22 additionalPaths?: Set<string>;
23}
24/** Manages the language server lifecycles and their associated objects necessary for adapting them to Atom IDE. */
25export declare class ServerManager {
26 private _startServer;
27 private _logger;
28 private _startForEditor;
29 private _changeWatchedFileFilter;
30 private _reportBusyWhile;
31 private _languageServerName;
32 private _determineProjectPath;
33 private shutdownGracefully;
34 private _activeServers;
35 private _startingServerPromises;
36 private _restartCounterPerProject;
37 private _stoppingServers;
38 private _disposable;
39 private _editorToServer;
40 private _normalizedProjectPaths;
41 private _previousNormalizedProjectPaths;
42 private _isStarted;
43 constructor(_startServer: (projectPath: string) => Promise<ActiveServer>, _logger: Logger, _startForEditor: (editor: TextEditor) => boolean, _changeWatchedFileFilter: (filePath: string) => boolean, _reportBusyWhile: ReportBusyWhile, _languageServerName: string, _determineProjectPath: (textEditor: TextEditor) => string | null, shutdownGracefully: boolean);
44 startListening(): void;
45 stopListening(): void;
46 private observeTextEditors;
47 private _handleTextEditor;
48 private _handleGrammarChange;
49 getActiveServers(): Readonly<ActiveServer[]>;
50 getServer(textEditor: TextEditor, { shouldStart }?: {
51 shouldStart?: boolean;
52 }): Promise<ActiveServer | null>;
53 startServer(projectPath: string): Promise<ActiveServer>;
54 stopUnusedServers(): Promise<void>;
55 stopAllServers(): Promise<void>;
56 restartAllServers(): Promise<void>;
57 hasServerReachedRestartLimit(server: ActiveServer): boolean;
58 stopServer(server: ActiveServer): Promise<void>;
59 exitServer(server: ActiveServer): void;
60 terminate(): void;
61 updateNormalizedProjectPaths(): void;
62 getNormalizedProjectPaths(): Readonly<string[]>;
63 /**
64 * Public: fetch the current open list of workspace folders
65 *
66 * @returns A {Promise} containing an {Array} of {lsp.WorkspaceFolder[]} or {null} if only a single file is open in the tool.
67 */
68 getWorkspaceFolders(): Promise<ls.WorkspaceFolder[] | null>;
69 projectPathsChanged(projectPaths: string[]): Promise<void>;
70 projectFilesChanged(fileEvents: FilesystemChangeEvent): void;
71 /** @deprecated Use the exported `normalizePath` function */
72 normalizePath: typeof normalizePath;
73}
74export declare function projectPathToWorkspaceFolder(projectPath: string): ls.WorkspaceFolder;
75export declare function normalizedProjectPathToWorkspaceFolder(normalizedProjectPath: string): ls.WorkspaceFolder;
76export declare function normalizePath(projectPath: string): string;
77/** Considers a path for inclusion in `additionalPaths`. */
78export declare function considerAdditionalPath(server: ActiveServer & {
79 additionalPaths: Set<string>;
80}, additionalPath: string): void;