1 | import { NotificationHandler, DidOpenTextDocumentParams, DidChangeTextDocumentParams, DidCloseTextDocumentParams, WillSaveTextDocumentParams, RequestHandler, TextEdit, DidSaveTextDocumentParams, DocumentUri, TextDocumentContentChangeEvent, TextDocumentSaveReason, Event, TextDocumentSyncKind, Disposable } from 'vscode-languageserver-protocol';
|
2 |
|
3 |
|
4 |
|
5 | export interface TextDocumentConnection {
|
6 | onDidOpenTextDocument(handler: NotificationHandler<DidOpenTextDocumentParams>): Disposable;
|
7 | onDidChangeTextDocument(handler: NotificationHandler<DidChangeTextDocumentParams>): Disposable;
|
8 | onDidCloseTextDocument(handler: NotificationHandler<DidCloseTextDocumentParams>): Disposable;
|
9 | onWillSaveTextDocument(handler: NotificationHandler<WillSaveTextDocumentParams>): Disposable;
|
10 | onWillSaveTextDocumentWaitUntil(handler: RequestHandler<WillSaveTextDocumentParams, TextEdit[] | undefined | null, void>): Disposable;
|
11 | onDidSaveTextDocument(handler: NotificationHandler<DidSaveTextDocumentParams>): Disposable;
|
12 | }
|
13 | export interface ConnectionState {
|
14 | __textDocumentSync: TextDocumentSyncKind | undefined;
|
15 | }
|
16 | export interface TextDocumentsConfiguration<T extends {
|
17 | uri: DocumentUri;
|
18 | }> {
|
19 | create(uri: DocumentUri, languageId: string, version: number, content: string): T;
|
20 | update(document: T, changes: TextDocumentContentChangeEvent[], version: number): T;
|
21 | }
|
22 |
|
23 |
|
24 |
|
25 | export interface TextDocumentChangeEvent<T> {
|
26 | |
27 |
|
28 |
|
29 | document: T;
|
30 | }
|
31 |
|
32 |
|
33 |
|
34 | export interface TextDocumentWillSaveEvent<T> {
|
35 | |
36 |
|
37 |
|
38 | document: T;
|
39 | |
40 |
|
41 |
|
42 | reason: TextDocumentSaveReason;
|
43 | }
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 | export declare class TextDocuments<T extends {
|
55 | uri: DocumentUri;
|
56 | }> {
|
57 | private readonly _configuration;
|
58 | private readonly _syncedDocuments;
|
59 | private readonly _onDidChangeContent;
|
60 | private readonly _onDidOpen;
|
61 | private readonly _onDidClose;
|
62 | private readonly _onDidSave;
|
63 | private readonly _onWillSave;
|
64 | private _willSaveWaitUntil;
|
65 | |
66 |
|
67 |
|
68 | constructor(configuration: TextDocumentsConfiguration<T>);
|
69 | /**
|
70 | * An event that fires when a text document managed by this manager
|
71 | * has been opened.
|
72 | */
|
73 | get onDidOpen(): Event<TextDocumentChangeEvent<T>>;
|
74 | /**
|
75 | * An event that fires when a text document managed by this manager
|
76 | * has been opened or the content changes.
|
77 | */
|
78 | get onDidChangeContent(): Event<TextDocumentChangeEvent<T>>;
|
79 | /**
|
80 | * An event that fires when a text document managed by this manager
|
81 | * will be saved.
|
82 | */
|
83 | get onWillSave(): Event<TextDocumentWillSaveEvent<T>>;
|
84 | /**
|
85 | * Sets a handler that will be called if a participant wants to provide
|
86 | * edits during a text document save.
|
87 | */
|
88 | onWillSaveWaitUntil(handler: RequestHandler<TextDocumentWillSaveEvent<T>, TextEdit[], void>): void;
|
89 | /**
|
90 | * An event that fires when a text document managed by this manager
|
91 | * has been saved.
|
92 | */
|
93 | get onDidSave(): Event<TextDocumentChangeEvent<T>>;
|
94 | /**
|
95 | * An event that fires when a text document managed by this manager
|
96 | * has been closed.
|
97 | */
|
98 | get onDidClose(): Event<TextDocumentChangeEvent<T>>;
|
99 | /**
|
100 | * Returns the document for the given URI. Returns undefined if
|
101 | * the document is not managed by this instance.
|
102 | *
|
103 | * @param uri The text document's URI to retrieve.
|
104 | * @return the text document or `undefined`.
|
105 | */
|
106 | get(uri: string): T | undefined;
|
107 | /**
|
108 | * Returns all text documents managed by this instance.
|
109 | *
|
110 | * @return all text documents.
|
111 | */
|
112 | all(): T[];
|
113 | /**
|
114 | * Returns the URIs of all text documents managed by this instance.
|
115 | *
|
116 | * @return the URI's of all text documents.
|
117 | */
|
118 | keys(): string[];
|
119 | /**
|
120 | * Listens for `low level` notification on the given connection to
|
121 | * update the text documents managed by this instance.
|
122 | *
|
123 | * Please note that the connection only provides handlers not an event model. Therefore
|
124 | * listening on a connection will overwrite the following handlers on a connection:
|
125 | * `onDidOpenTextDocument`, `onDidChangeTextDocument`, `onDidCloseTextDocument`,
|
126 | * `onWillSaveTextDocument`, `onWillSaveTextDocumentWaitUntil` and `onDidSaveTextDocument`.
|
127 | *
|
128 | * Use the corresponding events on the TextDocuments instance instead.
|
129 | *
|
130 | * @param connection The connection to listen on.
|
131 | */
|
132 | listen(connection: TextDocumentConnection): Disposable;
|
133 | }
|