UNPKG

lsp-ws-connection

Version:
115 lines (114 loc) 4.69 kB
/// <reference types="node" /> import * as events from 'events'; import 'setimmediate'; import type * as protocol from 'vscode-languageserver-protocol'; import { MessageConnection } from 'vscode-ws-jsonrpc'; import { AnyLocation, IDocumentInfo, ILspConnection, ILspOptions, IPosition, ITokenInfo } from './types'; /** * Changes as compared to upstream: * - markdown is preferred over plaintext * - informative members are public and others are protected, not private * - onServerInitialized() was extracted; it also emits a message once connected * - initializeParams() was extracted, and can be modified by subclasses * - typescript 3.7 was adopted to clean up deep references */ export declare class LspWsConnection extends events.EventEmitter implements ILspConnection { isConnected: boolean; isInitialized: boolean; documentInfo: ILspOptions; serverCapabilities: protocol.ServerCapabilities; protected socket: WebSocket; protected connection: MessageConnection; protected openedUris: Map<string, boolean>; private rootUri; constructor(options: ILspOptions); get isReady(): boolean; /** * Initialize a connection over a web socket that speaks the LSP protocol */ connect(socket: WebSocket): this; close(): void; /** * Initialization parameters to be sent to the language server. * Subclasses should override this when adding more features. */ protected initializeParams(): protocol.InitializeParams; sendInitialize(): void; sendOpen(documentInfo: IDocumentInfo): void; sendChange(documentInfo: IDocumentInfo): void; sendSaved(documentInfo: IDocumentInfo): void; sendConfigurationChange(settings: protocol.DidChangeConfigurationParams): void; /** * @deprecated */ getHoverTooltip(location: IPosition, documentInfo: IDocumentInfo, emit?: boolean): Promise<protocol.Hover | undefined>; /** * @deprecated */ getCompletion(location: IPosition, token: ITokenInfo, documentInfo: IDocumentInfo, emit?: boolean, triggerCharacter?: string, triggerKind?: protocol.CompletionTriggerKind): Promise<protocol.CompletionItem[] | undefined>; getDetailedCompletion(completionItem: protocol.CompletionItem): void; /** * @deprecated */ getSignatureHelp(location: IPosition, documentInfo: IDocumentInfo, emit?: boolean): Promise<protocol.SignatureHelp | undefined>; /** * Request the locations of all matching document symbols * @deprecated */ getDocumentHighlights(location: IPosition, documentInfo: IDocumentInfo, emit?: boolean): Promise<protocol.DocumentHighlight[] | undefined>; /** * Request a link to the definition of the current symbol. The results will not be displayed * unless they are within the same file URI * @deprecated */ getDefinition(location: IPosition, documentInfo: IDocumentInfo, emit?: boolean): Promise<AnyLocation>; /** * Request a link to the type definition of the current symbol. The results will not be displayed * unless they are within the same file URI * @deprecated */ getTypeDefinition(location: IPosition, documentInfo: IDocumentInfo, emit?: boolean): Promise<AnyLocation>; /** * Request a link to the implementation of the current symbol. The results will not be displayed * unless they are within the same file URI * @deprecated */ getImplementation(location: IPosition, documentInfo: IDocumentInfo): void; /** * Request a link to all references to the current symbol. The results will not be displayed * unless they are within the same file URI * @deprecated */ getReferences(location: IPosition, documentInfo: IDocumentInfo, emit?: boolean): Promise<Location[] | undefined>; /** * The characters that trigger completion automatically. * @deprecated */ getLanguageCompletionCharacters(): string[]; /** * The characters that trigger signature help automatically. * @deprecated */ getLanguageSignatureCharacters(): string[]; /** * Does the server support go to definition? * @deprecated */ isDefinitionSupported(): boolean; /** * Does the server support go to type definition? * @deprecated */ isTypeDefinitionSupported(): boolean; /** * Does the server support go to implementation? * @deprecated */ isImplementationSupported(): boolean; /** * Does the server support find all references? * @deprecated */ isReferencesSupported(): boolean; protected onServerInitialized(params: protocol.InitializeResult): void; }