import { TextDocument, Disposable, OutputChannel, DiagnosticCollection, Diagnostic as VDiagnostic, Uri, CancellationToken, WorkspaceFolder as VWorkspaceFolder, FileCreateEvent, FileRenameEvent, FileDeleteEvent, FileWillCreateEvent, FileWillRenameEvent, FileWillDeleteEvent, CompletionItemProvider, HoverProvider, SignatureHelpProvider, DefinitionProvider, ReferenceProvider, DocumentHighlightProvider, CodeActionProvider, DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider, OnTypeFormattingEditProvider, RenameProvider, DocumentSymbolProvider, DocumentLinkProvider, DeclarationProvider, ImplementationProvider, DocumentColorProvider, SelectionRangeProvider, TypeDefinitionProvider, CallHierarchyProvider, LinkedEditingRangeProvider, TypeHierarchyProvider, WorkspaceSymbolProvider, ProviderResult, TextEdit as VTextEdit, InlineCompletionItemProvider } from 'vscode'; import { Message, MessageSignature, ResponseError, RequestType0, RequestType, NotificationType0, NotificationType, ProtocolRequestType, ProtocolRequestType0, RequestHandler, RequestHandler0, GenericRequestHandler, ProtocolNotificationType, ProtocolNotificationType0, NotificationHandler, NotificationHandler0, GenericNotificationHandler, MessageReader, MessageWriter, Trace, Event, RegistrationRequest, RegistrationParams, UnregistrationRequest, UnregistrationParams, InitializeParams, InitializeResult, DocumentSelector, DidChangeTextDocumentNotification, FileEvent, ProgressType, ProgressToken, ShowDocumentRequest, ShowDocumentParams, ShowDocumentResult, CancellationStrategy, InitializeError, WorkDoneProgressBegin, WorkDoneProgressReport, WorkDoneProgressEnd, DidOpenTextDocumentNotification, WillSaveTextDocumentNotification, WillSaveTextDocumentWaitUntilRequest, DidSaveTextDocumentNotification, DidCloseTextDocumentNotification, DidCreateFilesNotification, DidRenameFilesNotification, DidDeleteFilesNotification, WillRenameFilesRequest, WillCreateFilesRequest, WillDeleteFilesRequest, CompletionRequest, HoverRequest, SignatureHelpRequest, DefinitionRequest, ReferencesRequest, DocumentHighlightRequest, CodeActionRequest, CodeLensRequest, DocumentFormattingRequest, DocumentRangeFormattingRequest, DocumentOnTypeFormattingRequest, RenameRequest, DocumentSymbolRequest, DocumentLinkRequest, DocumentColorRequest, DeclarationRequest, FoldingRangeRequest, ImplementationRequest, SelectionRangeRequest, TypeDefinitionRequest, CallHierarchyPrepareRequest, SemanticTokensRegistrationType, LinkedEditingRangeRequest, TypeHierarchyPrepareRequest, InlineValueRequest, InlayHintRequest, WorkspaceSymbolRequest, TextDocumentRegistrationOptions, FileOperationRegistrationOptions, DocumentDiagnosticRequest, NotebookDocumentSyncRegistrationType, NotebookDocumentSyncRegistrationOptions, MessageStrategy, InlineCompletionRequest, InlineCompletionRegistrationOptions, ExecuteCommandRequest, ExecuteCommandOptions } from 'vscode-languageserver-protocol'; import * as c2p from './codeConverter'; import * as p2c from './protocolConverter'; import { DynamicFeature, FeatureClient, TextDocumentSendFeature, StaticFeature, TextDocumentProviderFeature, WorkspaceProviderFeature } from './features'; import { DiagnosticProviderMiddleware, DiagnosticProviderShape, $DiagnosticPullOptions } from './diagnostic'; import { NotebookDocumentMiddleware, $NotebookDocumentOptions, NotebookDocumentProviderShape } from './notebook'; import { ConfigurationMiddleware, $ConfigurationOptions, DidChangeConfigurationMiddleware } from './configuration'; import { DidChangeTextDocumentFeatureShape, DidCloseTextDocumentFeatureShape, DidOpenTextDocumentFeatureShape, DidSaveTextDocumentFeatureShape, TextDocumentSynchronizationMiddleware } from './textSynchronization'; import { CompletionMiddleware } from './completion'; import { HoverMiddleware } from './hover'; import { DefinitionMiddleware } from './definition'; import { SignatureHelpMiddleware } from './signatureHelp'; import { DocumentHighlightMiddleware } from './documentHighlight'; import { DocumentSymbolMiddleware } from './documentSymbol'; import { WorkspaceSymbolMiddleware } from './workspaceSymbol'; import { ReferencesMiddleware } from './reference'; import { TypeDefinitionMiddleware } from './typeDefinition'; import { ImplementationMiddleware } from './implementation'; import { ColorProviderMiddleware } from './colorProvider'; import { CodeActionMiddleware } from './codeAction'; import { CodeLensMiddleware, CodeLensProviderShape } from './codeLens'; import { FormattingMiddleware } from './formatting'; import { RenameMiddleware } from './rename'; import { DocumentLinkMiddleware } from './documentLink'; import { ExecuteCommandMiddleware } from './executeCommand'; import { FoldingRangeProviderMiddleware, FoldingRangeProviderShape } from './foldingRange'; import { DeclarationMiddleware } from './declaration'; import { SelectionRangeProviderMiddleware } from './selectionRange'; import { CallHierarchyMiddleware } from './callHierarchy'; import { SemanticTokensMiddleware, SemanticTokensProviderShape } from './semanticTokens'; import { LinkedEditingRangeMiddleware } from './linkedEditingRange'; import { TypeHierarchyMiddleware } from './typeHierarchy'; import { InlineValueMiddleware, InlineValueProviderShape } from './inlineValue'; import { InlayHintsMiddleware, InlayHintsProviderShape } from './inlayHint'; import { WorkspaceFolderMiddleware } from './workspaceFolder'; import { FileOperationsMiddleware } from './fileOperations'; import { InlineCompletionMiddleware } from './inlineCompletion'; /** * Controls when the output channel is revealed. */ export declare enum RevealOutputChannelOn { Debug = 0, Info = 1, Warn = 2, Error = 3, Never = 4 } /** * A handler that is invoked when the initialization of the server failed. */ export type InitializationFailedHandler = /** * @param error The error returned from the server * @returns if true is returned the client tries to reinitialize the server. * Implementors of a handler are responsible to not initialize the server * infinitely. Return false if initialization should stop and an error * should be reported. */ (error: ResponseError | Error | any) => boolean; /** * An action to be performed when the connection is producing errors. */ export declare enum ErrorAction { /** * Continue running the server. */ Continue = 1, /** * Shutdown the server. */ Shutdown = 2 } export type ErrorHandlerResult = { /** * The action to take. */ action: ErrorAction; /** * An optional message to be presented to the user. */ message?: string; /** * If set to true the client assumes that the corresponding * error handler has presented an appropriate message to the * user and the message will only be log to the client's * output channel. */ handled?: boolean; }; /** * An action to be performed when the connection to a server got closed. */ export declare enum CloseAction { /** * Don't restart the server. The connection stays closed. */ DoNotRestart = 1, /** * Restart the server. */ Restart = 2 } export type CloseHandlerResult = { /** * The action to take. */ action: CloseAction; /** * An optional message to be presented to the user. */ message?: string; /** * If set to true the client assumes that the corresponding * close handler has presented an appropriate message to the * user and the message will only be log to the client's * output channel. */ handled?: boolean; }; /** * A plugable error handler that is invoked when the connection is either * producing errors or got closed. */ export interface ErrorHandler { /** * An error has occurred while writing or reading from the connection. * * @param error - the error received * @param message - the message to be delivered to the server if know. * @param count - a count indicating how often an error is received. Will * be reset if a message got successfully send or received. */ error(error: Error, message: Message | undefined, count: number | undefined): ErrorHandlerResult | Promise; /** * The connection to the server got closed. */ closed(): CloseHandlerResult | Promise; } /** * Signals in which state the language client is in. */ export declare enum State { /** * The client is stopped or got never started. */ Stopped = 1, /** * The client is starting but not ready yet. */ Starting = 3, /** * The client is running and ready. */ Running = 2 } /** * An event signaling a state change. */ export interface StateChangeEvent { oldState: State; newState: State; } export declare enum SuspendMode { /** * Don't allow suspend mode. */ off = "off", /** * Support suspend mode even if not all * registered providers have a corresponding * activation listener. */ on = "on" } export type SuspendOptions = { /** * Whether suspend mode is supported. If suspend mode is allowed * the client will stop a running server when going into suspend mode. * If omitted defaults to SuspendMode.off; */ mode?: SuspendMode; /** * A callback that is invoked before actually suspending * the server. If `false` is returned the client will not continue * suspending the server. */ callback?: () => Promise; /** * The interval in milliseconds used to check if the server * can be suspended. If the check passes three times in a row * (e.g. the server can be suspended for 3 * interval ms) the * server is suspended. Defaults to 60000ms, which is also the * minimum allowed value. */ interval?: number; }; export interface DidChangeWatchedFileSignature { (this: void, event: FileEvent): Promise; } type _WorkspaceMiddleware = { didChangeWatchedFile?: (this: void, event: FileEvent, next: DidChangeWatchedFileSignature) => Promise; }; export type WorkspaceMiddleware = _WorkspaceMiddleware & ConfigurationMiddleware & DidChangeConfigurationMiddleware & WorkspaceFolderMiddleware & FileOperationsMiddleware; interface _WindowMiddleware { showDocument?: (this: void, params: ShowDocumentParams, next: ShowDocumentRequest.HandlerSignature) => Promise; } export type WindowMiddleware = _WindowMiddleware; export interface HandleDiagnosticsSignature { (this: void, uri: Uri, diagnostics: VDiagnostic[]): void; } export interface HandleWorkDoneProgressSignature { (this: void, token: ProgressToken, params: WorkDoneProgressBegin | WorkDoneProgressReport | WorkDoneProgressEnd): void; } interface _Middleware { handleDiagnostics?: (this: void, uri: Uri, diagnostics: VDiagnostic[], next: HandleDiagnosticsSignature) => void; handleWorkDoneProgress?: (this: void, token: ProgressToken, params: WorkDoneProgressBegin | WorkDoneProgressReport | WorkDoneProgressEnd, next: HandleWorkDoneProgressSignature) => void; handleRegisterCapability?: (this: void, params: RegistrationParams, next: RegistrationRequest.HandlerSignature) => Promise; handleUnregisterCapability?: (this: void, params: UnregistrationParams, next: UnregistrationRequest.HandlerSignature) => Promise; workspace?: WorkspaceMiddleware; window?: WindowMiddleware; } interface GeneralMiddleware { sendRequest?(this: void, type: string | MessageSignature, param: P | undefined, token: CancellationToken | undefined, next: (type: string | MessageSignature, param?: P, token?: CancellationToken) => Promise): Promise; sendNotification?(this: void, type: string | MessageSignature, next: (type: string | MessageSignature, params?: R) => Promise, params: R): Promise; } /** * The Middleware lets extensions intercept the request and notifications send and received * from the server */ export type Middleware = _Middleware & TextDocumentSynchronizationMiddleware & CompletionMiddleware & HoverMiddleware & DefinitionMiddleware & SignatureHelpMiddleware & DocumentHighlightMiddleware & DocumentSymbolMiddleware & WorkspaceSymbolMiddleware & ReferencesMiddleware & TypeDefinitionMiddleware & ImplementationMiddleware & ColorProviderMiddleware & CodeActionMiddleware & CodeLensMiddleware & FormattingMiddleware & RenameMiddleware & DocumentLinkMiddleware & ExecuteCommandMiddleware & FoldingRangeProviderMiddleware & DeclarationMiddleware & SelectionRangeProviderMiddleware & CallHierarchyMiddleware & SemanticTokensMiddleware & LinkedEditingRangeMiddleware & TypeHierarchyMiddleware & InlineValueMiddleware & InlayHintsMiddleware & NotebookDocumentMiddleware & DiagnosticProviderMiddleware & InlineCompletionMiddleware & GeneralMiddleware; export type LanguageClientOptions = { documentSelector?: DocumentSelector | string[]; diagnosticCollectionName?: string; outputChannel?: OutputChannel; outputChannelName?: string; traceOutputChannel?: OutputChannel; revealOutputChannelOn?: RevealOutputChannelOn; /** * The encoding use to read stdout and stderr. Defaults * to 'utf8' if omitted. */ stdioEncoding?: string; initializationOptions?: any | (() => any); initializationFailedHandler?: InitializationFailedHandler; progressOnInitialization?: boolean; errorHandler?: ErrorHandler; middleware?: Middleware; uriConverters?: { code2Protocol: c2p.URIConverter; protocol2Code: p2c.URIConverter; }; workspaceFolder?: VWorkspaceFolder; connectionOptions?: { cancellationStrategy?: CancellationStrategy; messageStrategy?: MessageStrategy; maxRestartCount?: number; }; markdown?: { isTrusted?: boolean | { readonly enabledCommands: readonly string[]; }; supportHtml?: boolean; }; } & $NotebookDocumentOptions & $DiagnosticPullOptions & $ConfigurationOptions; export interface MessageTransports { reader: MessageReader; writer: MessageWriter; detached?: boolean; } export declare namespace MessageTransports { function is(value: any): value is MessageTransports; } export declare abstract class BaseLanguageClient implements FeatureClient { private _id; private _name; private _clientOptions; private _state; private _onStart; private _onStop; private _connection; private _idleInterval; private readonly _ignoredRegistrations; private readonly _listeners; private _disposed; private readonly _notificationHandlers; private readonly _notificationDisposables; private readonly _pendingNotificationHandlers; private readonly _requestHandlers; private readonly _requestDisposables; private readonly _pendingRequestHandlers; private readonly _progressHandlers; private readonly _pendingProgressHandlers; private readonly _progressDisposables; private _initializeResult; private _outputChannel; private _disposeOutputChannel; private _traceOutputChannel; private _capabilities; private _diagnostics; private _syncedDocuments; private _didChangeTextDocumentFeature; private readonly _pendingOpenNotifications; private readonly _pendingChangeSemaphore; private readonly _pendingChangeDelayer; private _fileEvents; private _fileEventDelayer; private _telemetryEmitter; private _stateChangeEmitter; private _trace; private _traceFormat; private _tracer; private readonly _c2p; private readonly _p2c; constructor(id: string, name: string, clientOptions: LanguageClientOptions); get name(): string; get middleware(): Middleware; get clientOptions(): LanguageClientOptions; get protocol2CodeConverter(): p2c.Converter; get code2ProtocolConverter(): c2p.Converter; get onTelemetry(): Event; get onDidChangeState(): Event; get outputChannel(): OutputChannel; get traceOutputChannel(): OutputChannel; get diagnostics(): DiagnosticCollection | undefined; get state(): State; private get $state(); private set $state(value); private getPublicState; get initializeResult(): InitializeResult | undefined; sendRequest(type: ProtocolRequestType0, token?: CancellationToken): Promise; sendRequest(type: ProtocolRequestType, params: P, token?: CancellationToken): Promise; sendRequest(type: RequestType0, token?: CancellationToken): Promise; sendRequest(type: RequestType, params: P, token?: CancellationToken): Promise; sendRequest(method: string, token?: CancellationToken): Promise; sendRequest(method: string, param: any, token?: CancellationToken): Promise; onRequest(type: ProtocolRequestType0, handler: RequestHandler0): Disposable; onRequest(type: ProtocolRequestType, handler: RequestHandler): Disposable; onRequest(type: RequestType0, handler: RequestHandler0): Disposable; onRequest(type: RequestType, handler: RequestHandler): Disposable; onRequest(method: string, handler: GenericRequestHandler): Disposable; sendNotification(type: ProtocolNotificationType0): Promise; sendNotification(type: ProtocolNotificationType, params?: P): Promise; sendNotification(type: NotificationType0): Promise; sendNotification

(type: NotificationType

, params?: P): Promise; sendNotification(method: string): Promise; sendNotification(method: string, params: any): Promise; onNotification(type: ProtocolNotificationType0, handler: NotificationHandler0): Disposable; onNotification(type: ProtocolNotificationType, handler: NotificationHandler

): Disposable; onNotification(type: NotificationType0, handler: NotificationHandler0): Disposable; onNotification

(type: NotificationType

, handler: NotificationHandler

): Disposable; onNotification(method: string, handler: GenericNotificationHandler): Disposable; sendProgress

(type: ProgressType

, token: string | number, value: P): Promise; onProgress

(type: ProgressType

, token: string | number, handler: NotificationHandler

): Disposable; createDefaultErrorHandler(maxRestartCount?: number): ErrorHandler; setTrace(value: Trace): Promise; private data2String; debug(message: string, data?: any, showNotification?: boolean): void; info(message: string, data?: any, showNotification?: boolean): void; warn(message: string, data?: any, showNotification?: boolean): void; error(message: string, data?: any, showNotification?: boolean | 'force'): void; private logOutputMessage; private showNotificationMessage; private logTrace; private logObjectTrace; needsStart(): boolean; needsStop(): boolean; private activeConnection; isRunning(): boolean; start(): Promise; private createOnStartPromise; private initialize; private doInitialize; private _clientGetRootPath; stop(timeout?: number): Promise; dispose(timeout?: number): Promise; private shutdown; private cleanUp; private cleanUpChannel; private notifyFileEvent; private sendPendingFullTextDocumentChanges; private triggerPendingChangeDelivery; private _diagnosticQueue; private _diagnosticQueueState; private handleDiagnostics; private triggerDiagnosticQueue; private workDiagnosticQueue; private setDiagnostics; protected getLocale(): string; protected abstract createMessageTransports(encoding: string): Promise; private $start; private createConnection; protected handleConnectionClosed(): Promise; private handleConnectionError; private hookConfigurationChanged; private refreshTrace; private hookFileEvents; private readonly _features; private readonly _dynamicFeatures; registerFeatures(features: (StaticFeature | DynamicFeature)[]): void; registerFeature(feature: StaticFeature | DynamicFeature): void; getFeature(request: typeof DidOpenTextDocumentNotification.method): DidOpenTextDocumentFeatureShape; getFeature(request: typeof DidChangeTextDocumentNotification.method): DidChangeTextDocumentFeatureShape; getFeature(request: typeof WillSaveTextDocumentNotification.method): DynamicFeature & TextDocumentSendFeature<(textDocument: TextDocument) => Promise>; getFeature(request: typeof WillSaveTextDocumentWaitUntilRequest.method): DynamicFeature & TextDocumentSendFeature<(textDocument: TextDocument) => ProviderResult>; getFeature(request: typeof DidSaveTextDocumentNotification.method): DidSaveTextDocumentFeatureShape; getFeature(request: typeof DidCloseTextDocumentNotification.method): DidCloseTextDocumentFeatureShape; getFeature(request: typeof DidCreateFilesNotification.method): DynamicFeature & { send: (event: FileCreateEvent) => Promise; }; getFeature(request: typeof DidRenameFilesNotification.method): DynamicFeature & { send: (event: FileRenameEvent) => Promise; }; getFeature(request: typeof DidDeleteFilesNotification.method): DynamicFeature & { send: (event: FileDeleteEvent) => Promise; }; getFeature(request: typeof WillCreateFilesRequest.method): DynamicFeature & { send: (event: FileWillCreateEvent) => Promise; }; getFeature(request: typeof WillRenameFilesRequest.method): DynamicFeature & { send: (event: FileWillRenameEvent) => Promise; }; getFeature(request: typeof WillDeleteFilesRequest.method): DynamicFeature & { send: (event: FileWillDeleteEvent) => Promise; }; getFeature(request: typeof CompletionRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof HoverRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof SignatureHelpRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof DefinitionRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof ReferencesRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof DocumentHighlightRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof CodeActionRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof CodeLensRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof DocumentFormattingRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof DocumentRangeFormattingRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof DocumentOnTypeFormattingRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof RenameRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof DocumentSymbolRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof DocumentLinkRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof DocumentColorRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof DeclarationRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof FoldingRangeRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof ImplementationRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof SelectionRangeRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof TypeDefinitionRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof CallHierarchyPrepareRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof SemanticTokensRegistrationType.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof LinkedEditingRangeRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof TypeHierarchyPrepareRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof InlineValueRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof InlayHintRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof WorkspaceSymbolRequest.method): DynamicFeature & WorkspaceProviderFeature; getFeature(request: typeof DocumentDiagnosticRequest.method): DynamicFeature & TextDocumentProviderFeature | undefined; getFeature(request: typeof NotebookDocumentSyncRegistrationType.method): DynamicFeature & NotebookDocumentProviderShape | undefined; getFeature(request: typeof InlineCompletionRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof ExecuteCommandRequest.method): DynamicFeature; hasDedicatedTextSynchronizationFeature(textDocument: TextDocument): boolean; protected registerBuiltinFeatures(): void; registerProposedFeatures(): void; protected fillInitializeParams(params: InitializeParams): void; private computeClientCapabilities; private initializeFeatures; private handleRegistrationRequest; private doRegisterCapability; private handleUnregistrationRequest; private doUnregisterCapability; private workspaceEditLock; private handleApplyWorkspaceEdit; private static RequestsToCancelOnContentModified; private static CancellableResolveCalls; handleFailedRequest(type: MessageSignature, token: CancellationToken | undefined, error: any, defaultValue: T, showNotification?: boolean): T; } export declare namespace ProposedFeatures { function createAll(_client: FeatureClient): (StaticFeature | DynamicFeature)[]; } export {};