@depup/vscode-languageserver 10.1.1-depup.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/License.txt +11 -0
  2. package/README.md +25 -0
  3. package/bin/installServerIntoExtension +73 -0
  4. package/changes.json +5 -0
  5. package/eslint.config.js +10 -0
  6. package/lib/browser/main.d.ts +20 -0
  7. package/lib/browser/main.js +61 -0
  8. package/lib/common/api.d.ts +15 -0
  9. package/lib/common/api.js +35 -0
  10. package/lib/common/callHierarchy.d.ts +15 -0
  11. package/lib/common/callHierarchy.js +34 -0
  12. package/lib/common/configuration.d.ts +9 -0
  13. package/lib/common/configuration.js +71 -0
  14. package/lib/common/diagnostic.d.ts +29 -0
  15. package/lib/common/diagnostic.js +30 -0
  16. package/lib/common/fileOperations.d.ts +16 -0
  17. package/lib/common/fileOperations.js +43 -0
  18. package/lib/common/foldingRange.d.ts +22 -0
  19. package/lib/common/foldingRange.js +26 -0
  20. package/lib/common/inlayHint.d.ts +28 -0
  21. package/lib/common/inlayHint.js +30 -0
  22. package/lib/common/inlineCompletion.d.ts +18 -0
  23. package/lib/common/inlineCompletion.js +22 -0
  24. package/lib/common/inlineValue.d.ts +22 -0
  25. package/lib/common/inlineValue.js +25 -0
  26. package/lib/common/linkedEditingRange.d.ts +16 -0
  27. package/lib/common/linkedEditingRange.js +18 -0
  28. package/lib/common/moniker.d.ts +13 -0
  29. package/lib/common/moniker.js +23 -0
  30. package/lib/common/notebook.d.ts +99 -0
  31. package/lib/common/notebook.js +262 -0
  32. package/lib/common/progress.d.ts +25 -0
  33. package/lib/common/progress.js +172 -0
  34. package/lib/common/semanticTokens.d.ts +43 -0
  35. package/lib/common/semanticTokens.js +251 -0
  36. package/lib/common/server.d.ts +812 -0
  37. package/lib/common/server.js +798 -0
  38. package/lib/common/showDocument.d.ts +6 -0
  39. package/lib/common/showDocument.js +16 -0
  40. package/lib/common/textDocumentContent.d.ts +14 -0
  41. package/lib/common/textDocumentContent.js +25 -0
  42. package/lib/common/textDocuments.d.ts +133 -0
  43. package/lib/common/textDocuments.js +180 -0
  44. package/lib/common/typeHierarchy.d.ts +15 -0
  45. package/lib/common/typeHierarchy.js +34 -0
  46. package/lib/common/utils/is.d.ts +9 -0
  47. package/lib/common/utils/is.js +42 -0
  48. package/lib/common/utils/uuid.d.ts +22 -0
  49. package/lib/common/utils/uuid.js +98 -0
  50. package/lib/common/workspaceFolder.d.ts +7 -0
  51. package/lib/common/workspaceFolder.js +47 -0
  52. package/lib/node/files.d.ts +19 -0
  53. package/lib/node/files.js +295 -0
  54. package/lib/node/main.d.ts +60 -0
  55. package/lib/node/main.js +295 -0
  56. package/lib/node/resolve.d.ts +1 -0
  57. package/lib/node/resolve.js +20 -0
  58. package/package.json +65 -0
  59. package/thirdpartynotices.txt +84 -0
  60. package/typings/thenable.d.ts +5 -0
@@ -0,0 +1,22 @@
1
+ /* --------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ * ------------------------------------------------------------------------------------------ */
5
+ 'use strict';
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.InlineCompletionFeature = void 0;
8
+ const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
9
+ const InlineCompletionFeature = (Base) => {
10
+ return class extends Base {
11
+ get inlineCompletion() {
12
+ return {
13
+ on: (handler) => {
14
+ return this.connection.onRequest(vscode_languageserver_protocol_1.InlineCompletionRequest.type, (params, cancel) => {
15
+ return handler(params, cancel, this.attachWorkDoneProgress(params));
16
+ });
17
+ }
18
+ };
19
+ }
20
+ };
21
+ };
22
+ exports.InlineCompletionFeature = InlineCompletionFeature;
@@ -0,0 +1,22 @@
1
+ import { InlineValue, Disposable, InlineValueParams } from 'vscode-languageserver-protocol';
2
+ import type { Feature, _Languages, ServerRequestHandler } from './server';
3
+ /**
4
+ * Shape of the inline values feature
5
+ *
6
+ * @since 3.17.0
7
+ */
8
+ export interface InlineValueFeatureShape {
9
+ inlineValue: {
10
+ /**
11
+ * Ask the client to refresh all inline values.
12
+ */
13
+ refresh(): Promise<void>;
14
+ /**
15
+ * Installs a handler for the inline values request.
16
+ *
17
+ * @param handler The corresponding handler.
18
+ */
19
+ on(handler: ServerRequestHandler<InlineValueParams, InlineValue[] | undefined | null, InlineValue[], void>): Disposable;
20
+ };
21
+ }
22
+ export declare const InlineValueFeature: Feature<_Languages, InlineValueFeatureShape>;
@@ -0,0 +1,25 @@
1
+ /* --------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ * ------------------------------------------------------------------------------------------ */
5
+ 'use strict';
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.InlineValueFeature = void 0;
8
+ const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
9
+ const InlineValueFeature = (Base) => {
10
+ return class extends Base {
11
+ get inlineValue() {
12
+ return {
13
+ refresh: () => {
14
+ return this.connection.sendRequest(vscode_languageserver_protocol_1.InlineValueRefreshRequest.type);
15
+ },
16
+ on: (handler) => {
17
+ return this.connection.onRequest(vscode_languageserver_protocol_1.InlineValueRequest.type, (params, cancel) => {
18
+ return handler(params, cancel, this.attachWorkDoneProgress(params));
19
+ });
20
+ }
21
+ };
22
+ }
23
+ };
24
+ };
25
+ exports.InlineValueFeature = InlineValueFeature;
@@ -0,0 +1,16 @@
1
+ import { LinkedEditingRangeParams, LinkedEditingRanges, Disposable } from 'vscode-languageserver-protocol';
2
+ import type { Feature, _Languages, ServerRequestHandler } from './server';
3
+ /**
4
+ * Shape of the linked editing feature
5
+ *
6
+ * @since 3.16.0
7
+ */
8
+ export interface LinkedEditingRangeFeatureShape {
9
+ /**
10
+ * Installs a handler for the linked editing range request.
11
+ *
12
+ * @param handler The corresponding handler.
13
+ */
14
+ onLinkedEditingRange(handler: ServerRequestHandler<LinkedEditingRangeParams, LinkedEditingRanges | undefined | null, void, void>): Disposable;
15
+ }
16
+ export declare const LinkedEditingRangeFeature: Feature<_Languages, LinkedEditingRangeFeatureShape>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ /* --------------------------------------------------------------------------------------------
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License. See License.txt in the project root for license information.
5
+ * ------------------------------------------------------------------------------------------ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.LinkedEditingRangeFeature = void 0;
8
+ const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
9
+ const LinkedEditingRangeFeature = (Base) => {
10
+ return class extends Base {
11
+ onLinkedEditingRange(handler) {
12
+ return this.connection.onRequest(vscode_languageserver_protocol_1.LinkedEditingRangeRequest.type, (params, cancel) => {
13
+ return handler(params, cancel, this.attachWorkDoneProgress(params), undefined);
14
+ });
15
+ }
16
+ };
17
+ };
18
+ exports.LinkedEditingRangeFeature = LinkedEditingRangeFeature;
@@ -0,0 +1,13 @@
1
+ import { MonikerParams, Moniker, Disposable } from 'vscode-languageserver-protocol';
2
+ import type { Feature, _Languages, ServerRequestHandler } from './server';
3
+ /**
4
+ * Shape of the moniker feature
5
+ *
6
+ * @since 3.16.0
7
+ */
8
+ export interface MonikerFeatureShape {
9
+ moniker: {
10
+ on(handler: ServerRequestHandler<MonikerParams, Moniker[] | null, Moniker[], void>): Disposable;
11
+ };
12
+ }
13
+ export declare const MonikerFeature: Feature<_Languages, MonikerFeatureShape>;
@@ -0,0 +1,23 @@
1
+ /* --------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ * ------------------------------------------------------------------------------------------ */
5
+ 'use strict';
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.MonikerFeature = void 0;
8
+ const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
9
+ const MonikerFeature = (Base) => {
10
+ return class extends Base {
11
+ get moniker() {
12
+ return {
13
+ on: (handler) => {
14
+ const type = vscode_languageserver_protocol_1.MonikerRequest.type;
15
+ return this.connection.onRequest(type, (params, cancel) => {
16
+ return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
17
+ });
18
+ },
19
+ };
20
+ }
21
+ };
22
+ };
23
+ exports.MonikerFeature = MonikerFeature;
@@ -0,0 +1,99 @@
1
+ import { NotificationHandler1, Event, DocumentUri, URI, Disposable, DidOpenNotebookDocumentParams, DidChangeNotebookDocumentParams, DidSaveNotebookDocumentParams, DidCloseNotebookDocumentParams, NotebookDocument, NotebookCell, LSPObject } from 'vscode-languageserver-protocol';
2
+ import type { Feature, _Notebooks, Connection } from './server';
3
+ import { TextDocuments, TextDocumentsConfiguration } from './textDocuments';
4
+ /**
5
+ * Shape of the notebooks feature
6
+ *
7
+ * @since 3.17.0
8
+ */
9
+ export interface NotebookSyncFeatureShape {
10
+ synchronization: {
11
+ onDidOpenNotebookDocument(handler: NotificationHandler1<DidOpenNotebookDocumentParams>): Disposable;
12
+ onDidChangeNotebookDocument(handler: NotificationHandler1<DidChangeNotebookDocumentParams>): Disposable;
13
+ onDidSaveNotebookDocument(handler: NotificationHandler1<DidSaveNotebookDocumentParams>): Disposable;
14
+ onDidCloseNotebookDocument(handler: NotificationHandler1<DidCloseNotebookDocumentParams>): Disposable;
15
+ };
16
+ }
17
+ export declare const NotebookSyncFeature: Feature<_Notebooks, NotebookSyncFeatureShape>;
18
+ export type NotebookDocumentChangeEvent = {
19
+ /**
20
+ * The notebook document that changed.
21
+ */
22
+ notebookDocument: NotebookDocument;
23
+ /**
24
+ * The meta data change if any.
25
+ *
26
+ * Note: old and new should always be an object literal (e.g. LSPObject)
27
+ */
28
+ metadata?: {
29
+ old: LSPObject | undefined;
30
+ new: LSPObject | undefined;
31
+ };
32
+ /**
33
+ * The cell changes if any.
34
+ */
35
+ cells?: {
36
+ /**
37
+ * The cells that got added.
38
+ */
39
+ added: NotebookCell[];
40
+ /**
41
+ * The cells that got removed.
42
+ */
43
+ removed: NotebookCell[];
44
+ /**
45
+ * The cells that changed.
46
+ */
47
+ changed: {
48
+ /**
49
+ * The cell data has changed, excluding its
50
+ * text content which is reported via
51
+ * `textContentChanged`.
52
+ */
53
+ data: {
54
+ old: NotebookCell;
55
+ new: NotebookCell;
56
+ }[];
57
+ /**
58
+ * The text content of a cell has changed.
59
+ * The actual text is available via the `Notebooks`
60
+ * text document manager.
61
+ */
62
+ textContent: NotebookCell[];
63
+ };
64
+ };
65
+ };
66
+ export declare class NotebookDocuments<T extends {
67
+ uri: DocumentUri;
68
+ }> {
69
+ private readonly notebookDocuments;
70
+ private readonly notebookCellMap;
71
+ private readonly _onDidOpen;
72
+ private readonly _onDidSave;
73
+ private readonly _onDidChange;
74
+ private readonly _onDidClose;
75
+ private _cellTextDocuments;
76
+ constructor(configurationOrTextDocuments: TextDocumentsConfiguration<T> | TextDocuments<T>);
77
+ get cellTextDocuments(): TextDocuments<T>;
78
+ getCellTextDocument(cell: NotebookCell): T | undefined;
79
+ getNotebookDocument(uri: URI): NotebookDocument | undefined;
80
+ getNotebookCell(uri: DocumentUri): NotebookCell | undefined;
81
+ findNotebookDocumentForCell(cell: DocumentUri | NotebookCell): NotebookDocument | undefined;
82
+ get onDidOpen(): Event<NotebookDocument>;
83
+ get onDidSave(): Event<NotebookDocument>;
84
+ get onDidChange(): Event<NotebookDocumentChangeEvent>;
85
+ get onDidClose(): Event<NotebookDocument>;
86
+ /**
87
+ * Listens for `low level` notification on the given connection to
88
+ * update the notebook documents managed by this instance.
89
+ *
90
+ * Please note that the connection only provides handlers not an event model. Therefore
91
+ * listening on a connection will overwrite the following handlers on a connection:
92
+ * `onDidOpenNotebookDocument`, `onDidChangeNotebookDocument`, `onDidSaveNotebookDocument`,
93
+ * and `onDidCloseNotebookDocument`.
94
+ *
95
+ * @param connection The connection to listen on.
96
+ */
97
+ listen(connection: Connection): Disposable;
98
+ private updateCellMap;
99
+ }
@@ -0,0 +1,262 @@
1
+ /* --------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ * ------------------------------------------------------------------------------------------ */
5
+ 'use strict';
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.NotebookDocuments = exports.NotebookSyncFeature = void 0;
8
+ const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
9
+ const textDocuments_1 = require("./textDocuments");
10
+ const NotebookSyncFeature = (Base) => {
11
+ return class extends Base {
12
+ get synchronization() {
13
+ return {
14
+ onDidOpenNotebookDocument: (handler) => {
15
+ return this.connection.onNotification(vscode_languageserver_protocol_1.DidOpenNotebookDocumentNotification.type, (params) => {
16
+ return handler(params);
17
+ });
18
+ },
19
+ onDidChangeNotebookDocument: (handler) => {
20
+ return this.connection.onNotification(vscode_languageserver_protocol_1.DidChangeNotebookDocumentNotification.type, (params) => {
21
+ return handler(params);
22
+ });
23
+ },
24
+ onDidSaveNotebookDocument: (handler) => {
25
+ return this.connection.onNotification(vscode_languageserver_protocol_1.DidSaveNotebookDocumentNotification.type, (params) => {
26
+ return handler(params);
27
+ });
28
+ },
29
+ onDidCloseNotebookDocument: (handler) => {
30
+ return this.connection.onNotification(vscode_languageserver_protocol_1.DidCloseNotebookDocumentNotification.type, (params) => {
31
+ return handler(params);
32
+ });
33
+ }
34
+ };
35
+ }
36
+ };
37
+ };
38
+ exports.NotebookSyncFeature = NotebookSyncFeature;
39
+ class CellTextDocumentConnection {
40
+ static NULL_DISPOSE = Object.freeze({ dispose: () => { } });
41
+ openHandler;
42
+ changeHandler;
43
+ closeHandler;
44
+ onDidOpenTextDocument(handler) {
45
+ this.openHandler = handler;
46
+ return vscode_languageserver_protocol_1.Disposable.create(() => { this.openHandler = undefined; });
47
+ }
48
+ openTextDocument(params) {
49
+ return this.openHandler && this.openHandler(params);
50
+ }
51
+ onDidChangeTextDocument(handler) {
52
+ this.changeHandler = handler;
53
+ return vscode_languageserver_protocol_1.Disposable.create(() => { this.changeHandler = handler; });
54
+ }
55
+ changeTextDocument(params) {
56
+ return this.changeHandler && this.changeHandler(params);
57
+ }
58
+ onDidCloseTextDocument(handler) {
59
+ this.closeHandler = handler;
60
+ return vscode_languageserver_protocol_1.Disposable.create(() => { this.closeHandler = undefined; });
61
+ }
62
+ closeTextDocument(params) {
63
+ return this.closeHandler && this.closeHandler(params);
64
+ }
65
+ onWillSaveTextDocument() {
66
+ return CellTextDocumentConnection.NULL_DISPOSE;
67
+ }
68
+ onWillSaveTextDocumentWaitUntil() {
69
+ return CellTextDocumentConnection.NULL_DISPOSE;
70
+ }
71
+ onDidSaveTextDocument() {
72
+ return CellTextDocumentConnection.NULL_DISPOSE;
73
+ }
74
+ }
75
+ class NotebookDocuments {
76
+ notebookDocuments;
77
+ notebookCellMap;
78
+ _onDidOpen;
79
+ _onDidSave;
80
+ _onDidChange;
81
+ _onDidClose;
82
+ _cellTextDocuments;
83
+ constructor(configurationOrTextDocuments) {
84
+ if (configurationOrTextDocuments instanceof textDocuments_1.TextDocuments) {
85
+ this._cellTextDocuments = configurationOrTextDocuments;
86
+ }
87
+ else {
88
+ this._cellTextDocuments = new textDocuments_1.TextDocuments(configurationOrTextDocuments);
89
+ }
90
+ this.notebookDocuments = new Map();
91
+ this.notebookCellMap = new Map();
92
+ this._onDidOpen = new vscode_languageserver_protocol_1.Emitter();
93
+ this._onDidChange = new vscode_languageserver_protocol_1.Emitter();
94
+ this._onDidSave = new vscode_languageserver_protocol_1.Emitter();
95
+ this._onDidClose = new vscode_languageserver_protocol_1.Emitter();
96
+ }
97
+ get cellTextDocuments() {
98
+ return this._cellTextDocuments;
99
+ }
100
+ getCellTextDocument(cell) {
101
+ return this._cellTextDocuments.get(cell.document);
102
+ }
103
+ getNotebookDocument(uri) {
104
+ return this.notebookDocuments.get(uri);
105
+ }
106
+ getNotebookCell(uri) {
107
+ const value = this.notebookCellMap.get(uri);
108
+ return value && value[0];
109
+ }
110
+ findNotebookDocumentForCell(cell) {
111
+ const key = typeof cell === 'string' ? cell : cell.document;
112
+ const value = this.notebookCellMap.get(key);
113
+ return value && value[1];
114
+ }
115
+ get onDidOpen() {
116
+ return this._onDidOpen.event;
117
+ }
118
+ get onDidSave() {
119
+ return this._onDidSave.event;
120
+ }
121
+ get onDidChange() {
122
+ return this._onDidChange.event;
123
+ }
124
+ get onDidClose() {
125
+ return this._onDidClose.event;
126
+ }
127
+ /**
128
+ * Listens for `low level` notification on the given connection to
129
+ * update the notebook documents managed by this instance.
130
+ *
131
+ * Please note that the connection only provides handlers not an event model. Therefore
132
+ * listening on a connection will overwrite the following handlers on a connection:
133
+ * `onDidOpenNotebookDocument`, `onDidChangeNotebookDocument`, `onDidSaveNotebookDocument`,
134
+ * and `onDidCloseNotebookDocument`.
135
+ *
136
+ * @param connection The connection to listen on.
137
+ */
138
+ listen(connection) {
139
+ const cellTextDocumentConnection = new CellTextDocumentConnection();
140
+ const disposables = [];
141
+ disposables.push(this.cellTextDocuments.listen(cellTextDocumentConnection));
142
+ disposables.push(connection.notebooks.synchronization.onDidOpenNotebookDocument(async (params) => {
143
+ this.notebookDocuments.set(params.notebookDocument.uri, params.notebookDocument);
144
+ for (const cellTextDocument of params.cellTextDocuments) {
145
+ await cellTextDocumentConnection.openTextDocument({ textDocument: cellTextDocument });
146
+ }
147
+ this.updateCellMap(params.notebookDocument);
148
+ this._onDidOpen.fire(params.notebookDocument);
149
+ }));
150
+ disposables.push(connection.notebooks.synchronization.onDidChangeNotebookDocument(async (params) => {
151
+ const notebookDocument = this.notebookDocuments.get(params.notebookDocument.uri);
152
+ if (notebookDocument === undefined) {
153
+ return;
154
+ }
155
+ notebookDocument.version = params.notebookDocument.version;
156
+ const oldMetadata = notebookDocument.metadata;
157
+ let metadataChanged = false;
158
+ const change = params.change;
159
+ if (change.metadata !== undefined) {
160
+ metadataChanged = true;
161
+ notebookDocument.metadata = change.metadata;
162
+ }
163
+ const opened = [];
164
+ const closed = [];
165
+ const data = [];
166
+ const text = [];
167
+ if (change.cells !== undefined) {
168
+ const changedCells = change.cells;
169
+ if (changedCells.structure !== undefined) {
170
+ const array = changedCells.structure.array;
171
+ notebookDocument.cells.splice(array.start, array.deleteCount, ...(array.cells !== undefined ? array.cells : []));
172
+ // Additional open cell text documents.
173
+ if (changedCells.structure.didOpen !== undefined) {
174
+ for (const open of changedCells.structure.didOpen) {
175
+ await cellTextDocumentConnection.openTextDocument({ textDocument: open });
176
+ opened.push(open.uri);
177
+ }
178
+ }
179
+ // Additional closed cell test documents.
180
+ if (changedCells.structure.didClose) {
181
+ for (const close of changedCells.structure.didClose) {
182
+ await cellTextDocumentConnection.closeTextDocument({ textDocument: close });
183
+ closed.push(close.uri);
184
+ }
185
+ }
186
+ }
187
+ if (changedCells.data !== undefined) {
188
+ const cellUpdates = new Map(changedCells.data.map(cell => [cell.document, cell]));
189
+ for (let i = 0; i <= notebookDocument.cells.length; i++) {
190
+ const change = cellUpdates.get(notebookDocument.cells[i].document);
191
+ if (change !== undefined) {
192
+ const old = notebookDocument.cells.splice(i, 1, change);
193
+ data.push({ old: old[0], new: change });
194
+ cellUpdates.delete(change.document);
195
+ if (cellUpdates.size === 0) {
196
+ break;
197
+ }
198
+ }
199
+ }
200
+ }
201
+ if (changedCells.textContent !== undefined) {
202
+ for (const cellTextDocument of changedCells.textContent) {
203
+ await cellTextDocumentConnection.changeTextDocument({ textDocument: cellTextDocument.document, contentChanges: cellTextDocument.changes });
204
+ text.push(cellTextDocument.document.uri);
205
+ }
206
+ }
207
+ }
208
+ // Update internal data structure.
209
+ this.updateCellMap(notebookDocument);
210
+ const changeEvent = { notebookDocument };
211
+ if (metadataChanged) {
212
+ changeEvent.metadata = { old: oldMetadata, new: notebookDocument.metadata };
213
+ }
214
+ const added = [];
215
+ for (const open of opened) {
216
+ added.push(this.getNotebookCell(open));
217
+ }
218
+ const removed = [];
219
+ for (const close of closed) {
220
+ removed.push(this.getNotebookCell(close));
221
+ }
222
+ const textContent = [];
223
+ for (const change of text) {
224
+ textContent.push(this.getNotebookCell(change));
225
+ }
226
+ if (added.length > 0 || removed.length > 0 || data.length > 0 || textContent.length > 0) {
227
+ changeEvent.cells = { added, removed, changed: { data, textContent } };
228
+ }
229
+ if (changeEvent.metadata !== undefined || changeEvent.cells !== undefined) {
230
+ this._onDidChange.fire(changeEvent);
231
+ }
232
+ }));
233
+ disposables.push(connection.notebooks.synchronization.onDidSaveNotebookDocument((params) => {
234
+ const notebookDocument = this.notebookDocuments.get(params.notebookDocument.uri);
235
+ if (notebookDocument === undefined) {
236
+ return;
237
+ }
238
+ this._onDidSave.fire(notebookDocument);
239
+ }));
240
+ disposables.push(connection.notebooks.synchronization.onDidCloseNotebookDocument(async (params) => {
241
+ const notebookDocument = this.notebookDocuments.get(params.notebookDocument.uri);
242
+ if (notebookDocument === undefined) {
243
+ return;
244
+ }
245
+ this._onDidClose.fire(notebookDocument);
246
+ for (const cellTextDocument of params.cellTextDocuments) {
247
+ await cellTextDocumentConnection.closeTextDocument({ textDocument: cellTextDocument });
248
+ }
249
+ this.notebookDocuments.delete(params.notebookDocument.uri);
250
+ for (const cell of notebookDocument.cells) {
251
+ this.notebookCellMap.delete(cell.document);
252
+ }
253
+ }));
254
+ return vscode_languageserver_protocol_1.Disposable.create(() => { disposables.forEach(disposable => disposable.dispose()); });
255
+ }
256
+ updateCellMap(notebookDocument) {
257
+ for (const cell of notebookDocument.cells) {
258
+ this.notebookCellMap.set(cell.document, [cell, notebookDocument]);
259
+ }
260
+ }
261
+ }
262
+ exports.NotebookDocuments = NotebookDocuments;
@@ -0,0 +1,25 @@
1
+ import { CancellationToken, ProgressToken, ProgressType, WorkDoneProgressParams, PartialResultParams, RequestParam } from 'vscode-languageserver-protocol';
2
+ import type { Feature, _RemoteWindow } from './server';
3
+ export interface ProgressContext {
4
+ sendProgress<P>(type: ProgressType<P>, token: ProgressToken, value: NoInfer<RequestParam<P>>): void;
5
+ }
6
+ export interface WorkDoneProgressReporter {
7
+ begin(title: string, percentage?: number, message?: string, cancellable?: boolean): void;
8
+ report(percentage: number): void;
9
+ report(message: string): void;
10
+ report(percentage: number, message: string): void;
11
+ done(): void;
12
+ }
13
+ export interface WorkDoneProgressServerReporter extends WorkDoneProgressReporter {
14
+ readonly token: CancellationToken;
15
+ }
16
+ export interface WindowProgress {
17
+ attachWorkDoneProgress(token: ProgressToken | undefined): WorkDoneProgressReporter;
18
+ createWorkDoneProgress(): Promise<WorkDoneProgressServerReporter>;
19
+ }
20
+ export declare function attachWorkDone(connection: ProgressContext, params: WorkDoneProgressParams | undefined): WorkDoneProgressReporter;
21
+ export declare const ProgressFeature: Feature<_RemoteWindow, WindowProgress>;
22
+ export interface ResultProgressReporter<R> {
23
+ report(data: R): void;
24
+ }
25
+ export declare function attachPartialResult<R>(connection: ProgressContext, params: PartialResultParams): ResultProgressReporter<R> | undefined;