UNPKG

8.06 kBTypeScriptView Raw
1import { TextDocument, TextDocumentChangeEvent, TextDocumentWillSaveEvent, TextEdit as VTextEdit, DocumentSelector as VDocumentSelector, Event } from 'vscode';
2import { ClientCapabilities, DidChangeTextDocumentParams, DidCloseTextDocumentParams, DidOpenTextDocumentParams, DidSaveTextDocumentParams, DocumentSelector, ProtocolNotificationType, RegistrationType, ServerCapabilities, TextDocumentChangeRegistrationOptions, TextDocumentRegistrationOptions, TextDocumentSaveRegistrationOptions, TextDocumentSyncKind, TextDocumentSyncOptions, WillSaveTextDocumentParams } from 'vscode-languageserver-protocol';
3import { FeatureClient, TextDocumentEventFeature, DynamicFeature, NextSignature, TextDocumentSendFeature, NotifyingFeature, RegistrationData, DynamicDocumentFeature, NotificationSendEvent } from './features';
4export interface TextDocumentSynchronizationMiddleware {
5 didOpen?: NextSignature<TextDocument, Promise<void>>;
6 didChange?: NextSignature<TextDocumentChangeEvent, Promise<void>>;
7 willSave?: NextSignature<TextDocumentWillSaveEvent, Promise<void>>;
8 willSaveWaitUntil?: NextSignature<TextDocumentWillSaveEvent, Thenable<VTextEdit[]>>;
9 didSave?: NextSignature<TextDocument, Promise<void>>;
10 didClose?: NextSignature<TextDocument, Promise<void>>;
11}
12export interface DidOpenTextDocumentFeatureShape extends DynamicFeature<TextDocumentRegistrationOptions>, TextDocumentSendFeature<(textDocument: TextDocument) => Promise<void>>, NotifyingFeature<DidOpenTextDocumentParams> {
13 openDocuments: Iterable<TextDocument>;
14}
15export type ResolvedTextDocumentSyncCapabilities = {
16 resolvedTextDocumentSync?: TextDocumentSyncOptions;
17};
18export declare class DidOpenTextDocumentFeature extends TextDocumentEventFeature<DidOpenTextDocumentParams, TextDocument, TextDocumentSynchronizationMiddleware> implements DidOpenTextDocumentFeatureShape {
19 private readonly _syncedDocuments;
20 constructor(client: FeatureClient<TextDocumentSynchronizationMiddleware>, syncedDocuments: Map<string, TextDocument>);
21 get openDocuments(): IterableIterator<TextDocument>;
22 fillClientCapabilities(capabilities: ClientCapabilities): void;
23 initialize(capabilities: ServerCapabilities, documentSelector: DocumentSelector): void;
24 get registrationType(): RegistrationType<TextDocumentRegistrationOptions>;
25 register(data: RegistrationData<TextDocumentRegistrationOptions>): void;
26 protected getTextDocument(data: TextDocument): TextDocument;
27 protected notificationSent(textDocument: TextDocument, type: ProtocolNotificationType<DidOpenTextDocumentParams, TextDocumentRegistrationOptions>, params: DidOpenTextDocumentParams): void;
28}
29export interface DidCloseTextDocumentFeatureShape extends DynamicFeature<TextDocumentRegistrationOptions>, TextDocumentSendFeature<(textDocument: TextDocument) => Promise<void>>, NotifyingFeature<DidCloseTextDocumentParams> {
30}
31export declare class DidCloseTextDocumentFeature extends TextDocumentEventFeature<DidCloseTextDocumentParams, TextDocument, TextDocumentSynchronizationMiddleware> implements DidCloseTextDocumentFeatureShape {
32 private readonly _syncedDocuments;
33 private readonly _pendingTextDocumentChanges;
34 constructor(client: FeatureClient<TextDocumentSynchronizationMiddleware>, syncedDocuments: Map<string, TextDocument>, pendingTextDocumentChanges: Map<string, TextDocument>);
35 get registrationType(): RegistrationType<TextDocumentRegistrationOptions>;
36 fillClientCapabilities(capabilities: ClientCapabilities): void;
37 initialize(capabilities: ServerCapabilities, documentSelector: DocumentSelector): void;
38 protected callback(data: TextDocument): Promise<void>;
39 protected getTextDocument(data: TextDocument): TextDocument;
40 protected notificationSent(textDocument: TextDocument, type: ProtocolNotificationType<DidCloseTextDocumentParams, TextDocumentRegistrationOptions>, params: DidCloseTextDocumentParams): void;
41 unregister(id: string): void;
42}
43export interface DidChangeTextDocumentFeatureShape extends DynamicFeature<TextDocumentChangeRegistrationOptions>, TextDocumentSendFeature<(event: TextDocumentChangeEvent) => Promise<void>>, NotifyingFeature<DidChangeTextDocumentParams> {
44}
45export declare class DidChangeTextDocumentFeature extends DynamicDocumentFeature<TextDocumentChangeRegistrationOptions, TextDocumentSynchronizationMiddleware> implements DidChangeTextDocumentFeatureShape {
46 private _listener;
47 private readonly _changeData;
48 private readonly _onNotificationSent;
49 private readonly _onPendingChangeAdded;
50 private readonly _pendingTextDocumentChanges;
51 private _syncKind;
52 constructor(client: FeatureClient<TextDocumentSynchronizationMiddleware>, pendingTextDocumentChanges: Map<string, TextDocument>);
53 get onNotificationSent(): Event<NotificationSendEvent<DidChangeTextDocumentParams>>;
54 get onPendingChangeAdded(): Event<void>;
55 get syncKind(): TextDocumentSyncKind;
56 get registrationType(): RegistrationType<TextDocumentChangeRegistrationOptions>;
57 fillClientCapabilities(capabilities: ClientCapabilities): void;
58 initialize(capabilities: ServerCapabilities, documentSelector: DocumentSelector): void;
59 register(data: RegistrationData<TextDocumentChangeRegistrationOptions>): void;
60 getDocumentSelectors(): IterableIterator<VDocumentSelector>;
61 private callback;
62 notificationSent(textDocument: TextDocument, type: ProtocolNotificationType<DidChangeTextDocumentParams, TextDocumentRegistrationOptions>, params: DidChangeTextDocumentParams): void;
63 unregister(id: string): void;
64 clear(): void;
65 getPendingDocumentChanges(excludes: Set<string>): TextDocument[];
66 getProvider(document: TextDocument): {
67 send: (event: TextDocumentChangeEvent) => Promise<void>;
68 } | undefined;
69 private updateSyncKind;
70}
71export declare class WillSaveFeature extends TextDocumentEventFeature<WillSaveTextDocumentParams, TextDocumentWillSaveEvent, TextDocumentSynchronizationMiddleware> {
72 constructor(client: FeatureClient<TextDocumentSynchronizationMiddleware>);
73 get registrationType(): RegistrationType<TextDocumentRegistrationOptions>;
74 fillClientCapabilities(capabilities: ClientCapabilities): void;
75 initialize(capabilities: ServerCapabilities, documentSelector: DocumentSelector): void;
76 protected getTextDocument(data: TextDocumentWillSaveEvent): TextDocument;
77}
78export declare class WillSaveWaitUntilFeature extends DynamicDocumentFeature<TextDocumentRegistrationOptions, TextDocumentSynchronizationMiddleware> {
79 private _listener;
80 private readonly _selectors;
81 constructor(client: FeatureClient<TextDocumentSynchronizationMiddleware>);
82 protected getDocumentSelectors(): IterableIterator<VDocumentSelector>;
83 get registrationType(): RegistrationType<TextDocumentRegistrationOptions>;
84 fillClientCapabilities(capabilities: ClientCapabilities): void;
85 initialize(capabilities: ServerCapabilities, documentSelector: DocumentSelector): void;
86 register(data: RegistrationData<TextDocumentRegistrationOptions>): void;
87 private callback;
88 unregister(id: string): void;
89 clear(): void;
90}
91export interface DidSaveTextDocumentFeatureShape extends DynamicFeature<TextDocumentRegistrationOptions>, TextDocumentSendFeature<(textDocument: TextDocument) => Promise<void>>, NotifyingFeature<DidSaveTextDocumentParams> {
92}
93export declare class DidSaveTextDocumentFeature extends TextDocumentEventFeature<DidSaveTextDocumentParams, TextDocument, TextDocumentSynchronizationMiddleware> implements DidSaveTextDocumentFeatureShape {
94 private _includeText;
95 constructor(client: FeatureClient<TextDocumentSynchronizationMiddleware>);
96 get registrationType(): RegistrationType<TextDocumentSaveRegistrationOptions>;
97 fillClientCapabilities(capabilities: ClientCapabilities): void;
98 initialize(capabilities: ServerCapabilities, documentSelector: DocumentSelector): void;
99 register(data: RegistrationData<TextDocumentSaveRegistrationOptions>): void;
100 protected getTextDocument(data: TextDocument): TextDocument;
101}