1 | import { URI, integer, DocumentUri, uinteger, TextDocumentItem, TextDocumentIdentifier, VersionedTextDocumentIdentifier, LSPObject } from 'vscode-languageserver-types';
|
2 | import { MessageDirection, ProtocolNotificationType, RegistrationType } from './messages';
|
3 | import type { StaticRegistrationOptions, NotebookDocumentFilter, TextDocumentContentChangeEvent } from './protocol';
|
4 | /**
|
5 | * Notebook specific client capabilities.
|
6 | *
|
7 | * @since 3.17.0
|
8 | */
|
9 | export type NotebookDocumentSyncClientCapabilities = {
|
10 | /**
|
11 | * Whether implementation supports dynamic registration. If this is
|
12 | * set to `true` the client supports the new
|
13 | * `(TextDocumentRegistrationOptions & StaticRegistrationOptions)`
|
14 | * return value for the corresponding server capability as well.
|
15 | */
|
16 | dynamicRegistration?: boolean;
|
17 | /**
|
18 | * The client supports sending execution summary data per cell.
|
19 | */
|
20 | executionSummarySupport?: boolean;
|
21 | };
|
22 | /**
|
23 | * A notebook cell kind.
|
24 | *
|
25 | * @since 3.17.0
|
26 | */
|
27 | export declare namespace NotebookCellKind {
|
28 | /**
|
29 | * A markup-cell is formatted source that is used for display.
|
30 | */
|
31 | const Markup: 1;
|
32 | /**
|
33 | * A code-cell is source code.
|
34 | */
|
35 | const Code: 2;
|
36 | function is(value: any): value is NotebookCellKind;
|
37 | }
|
38 | export type NotebookCellKind = 1 | 2;
|
39 | export type ExecutionSummary = {
|
40 | /**
|
41 | * A strict monotonically increasing value
|
42 | * indicating the execution order of a cell
|
43 | * inside a notebook.
|
44 | */
|
45 | executionOrder: uinteger;
|
46 | /**
|
47 | * Whether the execution was successful or
|
48 | * not if known by the client.
|
49 | */
|
50 | success?: boolean;
|
51 | };
|
52 | export declare namespace ExecutionSummary {
|
53 | function create(executionOrder: number, success?: boolean): ExecutionSummary;
|
54 | function is(value: any): value is ExecutionSummary;
|
55 | function equals(one: ExecutionSummary | undefined, other: ExecutionSummary | undefined): boolean;
|
56 | }
|
57 | /**
|
58 | * A notebook cell.
|
59 | *
|
60 | * A cell's document URI must be unique across ALL notebook
|
61 | * cells and can therefore be used to uniquely identify a
|
62 | * notebook cell or the cell's text document.
|
63 | *
|
64 | * @since 3.17.0
|
65 | */
|
66 | export type NotebookCell = {
|
67 | /**
|
68 | * The cell's kind
|
69 | */
|
70 | kind: NotebookCellKind;
|
71 | /**
|
72 | * The URI of the cell's text document
|
73 | * content.
|
74 | */
|
75 | document: DocumentUri;
|
76 | /**
|
77 | * Additional metadata stored with the cell.
|
78 | *
|
79 | * Note: should always be an object literal (e.g. LSPObject)
|
80 | */
|
81 | metadata?: LSPObject;
|
82 | /**
|
83 | * Additional execution summary information
|
84 | * if supported by the client.
|
85 | */
|
86 | executionSummary?: ExecutionSummary;
|
87 | };
|
88 | export declare namespace NotebookCell {
|
89 | function create(kind: NotebookCellKind, document: DocumentUri): NotebookCell;
|
90 | function is(value: any): value is NotebookCell;
|
91 | function diff(one: NotebookCell, two: NotebookCell): Set<keyof NotebookCell>;
|
92 | }
|
93 | /**
|
94 | * A notebook document.
|
95 | *
|
96 | * @since 3.17.0
|
97 | */
|
98 | export type NotebookDocument = {
|
99 | /**
|
100 | * The notebook document's uri.
|
101 | */
|
102 | uri: URI;
|
103 | /**
|
104 | * The type of the notebook.
|
105 | */
|
106 | notebookType: string;
|
107 | /**
|
108 | * The version number of this document (it will increase after each
|
109 | * change, including undo/redo).
|
110 | */
|
111 | version: integer;
|
112 | /**
|
113 | * Additional metadata stored with the notebook
|
114 | * document.
|
115 | *
|
116 | * Note: should always be an object literal (e.g. LSPObject)
|
117 | */
|
118 | metadata?: LSPObject;
|
119 | /**
|
120 | * The cells of a notebook.
|
121 | */
|
122 | cells: NotebookCell[];
|
123 | };
|
124 | export declare namespace NotebookDocument {
|
125 | function create(uri: URI, notebookType: string, version: integer, cells: NotebookCell[]): NotebookDocument;
|
126 | function is(value: any): value is NotebookDocument;
|
127 | }
|
128 | /**
|
129 | * A literal to identify a notebook document in the client.
|
130 | *
|
131 | * @since 3.17.0
|
132 | */
|
133 | export type NotebookDocumentIdentifier = {
|
134 | /**
|
135 | * The notebook document's uri.
|
136 | */
|
137 | uri: URI;
|
138 | };
|
139 | /**
|
140 | * A versioned notebook document identifier.
|
141 | *
|
142 | * @since 3.17.0
|
143 | */
|
144 | export type VersionedNotebookDocumentIdentifier = {
|
145 | /**
|
146 | * The version number of this notebook document.
|
147 | */
|
148 | version: integer;
|
149 | /**
|
150 | * The notebook document's uri.
|
151 | */
|
152 | uri: URI;
|
153 | };
|
154 | /**
|
155 | * Options specific to a notebook plus its cells
|
156 | * to be synced to the server.
|
157 | *
|
158 | * If a selector provides a notebook document
|
159 | * filter but no cell selector all cells of a
|
160 | * matching notebook document will be synced.
|
161 | *
|
162 | * If a selector provides no notebook document
|
163 | * filter but only a cell selector all notebook
|
164 | * document that contain at least one matching
|
165 | * cell will be synced.
|
166 | *
|
167 | * @since 3.17.0
|
168 | */
|
169 | export type NotebookDocumentSyncOptions = {
|
170 | /**
|
171 | * The notebooks to be synced
|
172 | */
|
173 | notebookSelector: ({
|
174 | /**
|
175 | * The notebook to be synced If a string
|
176 | * value is provided it matches against the
|
177 | * notebook type. '*' matches every notebook.
|
178 | */
|
179 | notebook: string | NotebookDocumentFilter;
|
180 | /**
|
181 | * The cells of the matching notebook to be synced.
|
182 | */
|
183 | cells?: {
|
184 | language: string;
|
185 | }[];
|
186 | } | {
|
187 | /**
|
188 | * The notebook to be synced If a string
|
189 | * value is provided it matches against the
|
190 | * notebook type. '*' matches every notebook.
|
191 | */
|
192 | notebook?: string | NotebookDocumentFilter;
|
193 | /**
|
194 | * The cells of the matching notebook to be synced.
|
195 | */
|
196 | cells: {
|
197 | language: string;
|
198 | }[];
|
199 | })[];
|
200 | /**
|
201 | * Whether save notification should be forwarded to
|
202 | * the server. Will only be honored if mode === `notebook`.
|
203 | */
|
204 | save?: boolean;
|
205 | };
|
206 | /**
|
207 | * Registration options specific to a notebook.
|
208 | *
|
209 | * @since 3.17.0
|
210 | */
|
211 | export type NotebookDocumentSyncRegistrationOptions = NotebookDocumentSyncOptions & StaticRegistrationOptions;
|
212 | export declare namespace NotebookDocumentSyncRegistrationType {
|
213 | const method: 'notebookDocument/sync';
|
214 | const messageDirection: MessageDirection;
|
215 | const type: RegistrationType<NotebookDocumentSyncRegistrationOptions>;
|
216 | }
|
217 | /**
|
218 | * The params sent in an open notebook document notification.
|
219 | *
|
220 | * @since 3.17.0
|
221 | */
|
222 | export type DidOpenNotebookDocumentParams = {
|
223 | /**
|
224 | * The notebook document that got opened.
|
225 | */
|
226 | notebookDocument: NotebookDocument;
|
227 | /**
|
228 | * The text documents that represent the content
|
229 | * of a notebook cell.
|
230 | */
|
231 | cellTextDocuments: TextDocumentItem[];
|
232 | };
|
233 | /**
|
234 | * A notification sent when a notebook opens.
|
235 | *
|
236 | * @since 3.17.0
|
237 | */
|
238 | export declare namespace DidOpenNotebookDocumentNotification {
|
239 | const method: 'notebookDocument/didOpen';
|
240 | const messageDirection: MessageDirection;
|
241 | const type: ProtocolNotificationType<DidOpenNotebookDocumentParams, void>;
|
242 | const registrationMethod: typeof NotebookDocumentSyncRegistrationType.method;
|
243 | }
|
244 | /**
|
245 | * A change describing how to move a `NotebookCell`
|
246 | * array from state S to S'.
|
247 | *
|
248 | * @since 3.17.0
|
249 | */
|
250 | export type NotebookCellArrayChange = {
|
251 | /**
|
252 | * The start oftest of the cell that changed.
|
253 | */
|
254 | start: uinteger;
|
255 | /**
|
256 | * The deleted cells
|
257 | */
|
258 | deleteCount: uinteger;
|
259 | /**
|
260 | * The new cells, if any
|
261 | */
|
262 | cells?: NotebookCell[];
|
263 | };
|
264 | export declare namespace NotebookCellArrayChange {
|
265 | function is(value: any): value is NotebookCellArrayChange;
|
266 | function create(start: uinteger, deleteCount: uinteger, cells?: NotebookCell[]): NotebookCellArrayChange;
|
267 | }
|
268 | /**
|
269 | * A change event for a notebook document.
|
270 | *
|
271 | * @since 3.17.0
|
272 | */
|
273 | export type NotebookDocumentChangeEvent = {
|
274 | /**
|
275 | * The changed meta data if any.
|
276 | *
|
277 | * Note: should always be an object literal (e.g. LSPObject)
|
278 | */
|
279 | metadata?: LSPObject;
|
280 | /**
|
281 | * Changes to cells
|
282 | */
|
283 | cells?: {
|
284 | /**
|
285 | * Changes to the cell structure to add or
|
286 | * remove cells.
|
287 | */
|
288 | structure?: {
|
289 | /**
|
290 | * The change to the cell array.
|
291 | */
|
292 | array: NotebookCellArrayChange;
|
293 | /**
|
294 | * Additional opened cell text documents.
|
295 | */
|
296 | didOpen?: TextDocumentItem[];
|
297 | /**
|
298 | * Additional closed cell text documents.
|
299 | */
|
300 | didClose?: TextDocumentIdentifier[];
|
301 | };
|
302 | /**
|
303 | * Changes to notebook cells properties like its
|
304 | * kind, execution summary or metadata.
|
305 | */
|
306 | data?: NotebookCell[];
|
307 | /**
|
308 | * Changes to the text content of notebook cells.
|
309 | */
|
310 | textContent?: {
|
311 | document: VersionedTextDocumentIdentifier;
|
312 | changes: TextDocumentContentChangeEvent[];
|
313 | }[];
|
314 | };
|
315 | };
|
316 | /**
|
317 | * The params sent in a change notebook document notification.
|
318 | *
|
319 | * @since 3.17.0
|
320 | */
|
321 | export type DidChangeNotebookDocumentParams = {
|
322 | /**
|
323 | * The notebook document that did change. The version number points
|
324 | * to the version after all provided changes have been applied. If
|
325 | * only the text document content of a cell changes the notebook version
|
326 | * doesn't necessarily have to change.
|
327 | */
|
328 | notebookDocument: VersionedNotebookDocumentIdentifier;
|
329 | /**
|
330 | * The actual changes to the notebook document.
|
331 | *
|
332 | * The changes describe single state changes to the notebook document.
|
333 | * So if there are two changes c1 (at array index 0) and c2 (at array
|
334 | * index 1) for a notebook in state S then c1 moves the notebook from
|
335 | * S to S' and c2 from S' to S''. So c1 is computed on the state S and
|
336 | * c2 is computed on the state S'.
|
337 | *
|
338 | * To mirror the content of a notebook using change events use the following approach:
|
339 | * - start with the same initial content
|
340 | * - apply the 'notebookDocument/didChange' notifications in the order you receive them.
|
341 | * - apply the `NotebookChangeEvent`s in a single notification in the order
|
342 | * you receive them.
|
343 | */
|
344 | change: NotebookDocumentChangeEvent;
|
345 | };
|
346 | export declare namespace DidChangeNotebookDocumentNotification {
|
347 | const method: 'notebookDocument/didChange';
|
348 | const messageDirection: MessageDirection;
|
349 | const type: ProtocolNotificationType<DidChangeNotebookDocumentParams, void>;
|
350 | const registrationMethod: typeof NotebookDocumentSyncRegistrationType.method;
|
351 | }
|
352 | /**
|
353 | * The params sent in a save notebook document notification.
|
354 | *
|
355 | * @since 3.17.0
|
356 | */
|
357 | export type DidSaveNotebookDocumentParams = {
|
358 | /**
|
359 | * The notebook document that got saved.
|
360 | */
|
361 | notebookDocument: NotebookDocumentIdentifier;
|
362 | };
|
363 | /**
|
364 | * A notification sent when a notebook document is saved.
|
365 | *
|
366 | * @since 3.17.0
|
367 | */
|
368 | export declare namespace DidSaveNotebookDocumentNotification {
|
369 | const method: 'notebookDocument/didSave';
|
370 | const messageDirection: MessageDirection;
|
371 | const type: ProtocolNotificationType<DidSaveNotebookDocumentParams, void>;
|
372 | const registrationMethod: typeof NotebookDocumentSyncRegistrationType.method;
|
373 | }
|
374 | /**
|
375 | * The params sent in a close notebook document notification.
|
376 | *
|
377 | * @since 3.17.0
|
378 | */
|
379 | export type DidCloseNotebookDocumentParams = {
|
380 | /**
|
381 | * The notebook document that got closed.
|
382 | */
|
383 | notebookDocument: NotebookDocumentIdentifier;
|
384 | /**
|
385 | * The text documents that represent the content
|
386 | * of a notebook cell that got closed.
|
387 | */
|
388 | cellTextDocuments: TextDocumentIdentifier[];
|
389 | };
|
390 | /**
|
391 | * A notification sent when a notebook closes.
|
392 | *
|
393 | * @since 3.17.0
|
394 | */
|
395 | export declare namespace DidCloseNotebookDocumentNotification {
|
396 | const method: 'notebookDocument/didClose';
|
397 | const messageDirection: MessageDirection;
|
398 | const type: ProtocolNotificationType<DidCloseNotebookDocumentParams, void>;
|
399 | const registrationMethod: typeof NotebookDocumentSyncRegistrationType.method;
|
400 | }
|