@jupyterlab/lsp 4.0.0-alpha.11 → 4.0.0-alpha.12
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.
- package/lib/adapters/adapter.d.ts +184 -54
- package/lib/adapters/adapter.js +177 -132
- package/lib/adapters/adapter.js.map +1 -1
- package/lib/adapters/statusmessage.d.ts +47 -0
- package/lib/adapters/statusmessage.js +74 -0
- package/lib/adapters/statusmessage.js.map +1 -0
- package/lib/connection.d.ts +113 -26
- package/lib/connection.js +166 -105
- package/lib/connection.js.map +1 -1
- package/lib/connection_manager.d.ts +143 -18
- package/lib/connection_manager.js +163 -49
- package/lib/connection_manager.js.map +1 -1
- package/lib/extractors/index.d.ts +3 -0
- package/lib/extractors/index.js +6 -0
- package/lib/extractors/index.js.map +1 -0
- package/lib/extractors/manager.d.ts +21 -4
- package/lib/extractors/manager.js +22 -5
- package/lib/extractors/manager.js.map +1 -1
- package/lib/extractors/text_extractor.d.ts +34 -7
- package/lib/extractors/text_extractor.js +11 -0
- package/lib/extractors/text_extractor.js.map +1 -1
- package/lib/extractors/types.d.ts +8 -6
- package/lib/extractors/types.js +2 -0
- package/lib/extractors/types.js.map +1 -1
- package/lib/feature.d.ts +18 -3
- package/lib/feature.js +20 -3
- package/lib/feature.js.map +1 -1
- package/lib/index.d.ts +6 -9
- package/lib/index.js +8 -13
- package/lib/index.js.map +1 -1
- package/lib/lsp.d.ts +10 -4
- package/lib/lsp.js +2 -0
- package/lib/lsp.js.map +1 -1
- package/lib/manager.d.ts +103 -16
- package/lib/manager.js +118 -31
- package/lib/manager.js.map +1 -1
- package/lib/plugin.d.ts +18 -13
- package/lib/plugin.js +2 -1
- package/lib/plugin.js.map +1 -1
- package/lib/positioning.d.ts +43 -6
- package/lib/positioning.js +28 -2
- package/lib/positioning.js.map +1 -1
- package/lib/schema.js +2 -1
- package/lib/schema.js.map +1 -1
- package/lib/tokens.d.ts +275 -45
- package/lib/tokens.js +28 -0
- package/lib/tokens.js.map +1 -1
- package/lib/utils.d.ts +15 -1
- package/lib/utils.js +18 -2
- package/lib/utils.js.map +1 -1
- package/lib/virtual/document.d.ts +374 -78
- package/lib/virtual/document.js +375 -148
- package/lib/virtual/document.js.map +1 -1
- package/lib/ws-connection/server-capability-registration.d.ts +18 -0
- package/lib/ws-connection/server-capability-registration.js +46 -0
- package/lib/ws-connection/server-capability-registration.js.map +1 -0
- package/lib/ws-connection/types.d.ts +75 -0
- package/lib/ws-connection/types.js +7 -0
- package/lib/ws-connection/types.js.map +1 -0
- package/lib/ws-connection/ws-connection.d.ts +82 -0
- package/lib/ws-connection/ws-connection.js +201 -0
- package/lib/ws-connection/ws-connection.js.map +1 -0
- package/package.json +15 -16
- package/style/index.css +0 -2
- package/style/index.js +0 -2
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IDisposable } from '@lumino/disposable';
|
|
2
|
+
import { IDocumentInfo } from '../ws-connection/types';
|
|
3
|
+
import { IPosition } from '../positioning';
|
|
2
4
|
import { CodeEditor } from '@jupyterlab/codeeditor';
|
|
3
|
-
import {
|
|
4
|
-
import { Signal } from '@lumino/signaling';
|
|
5
|
+
import { ISignal } from '@lumino/signaling';
|
|
5
6
|
import { ILSPCodeExtractorsManager } from '../';
|
|
6
7
|
import { LanguageIdentifier } from '../lsp';
|
|
7
8
|
import { IEditorPosition, IRootPosition, ISourcePosition, IVirtualPosition } from '../positioning';
|
|
8
9
|
import { DefaultMap } from '../utils';
|
|
9
|
-
import type * as CodeMirror from 'codemirror';
|
|
10
10
|
declare type IRange = CodeEditor.IRange;
|
|
11
11
|
declare type language = string;
|
|
12
12
|
interface IVirtualLine {
|
|
@@ -18,26 +18,56 @@ interface IVirtualLine {
|
|
|
18
18
|
* Where does the virtual line belongs to in the source document?
|
|
19
19
|
*/
|
|
20
20
|
sourceLine: number | null;
|
|
21
|
+
/**
|
|
22
|
+
* The editor holding this virtual line
|
|
23
|
+
*/
|
|
21
24
|
editor: CodeEditor.IEditor;
|
|
22
25
|
}
|
|
23
26
|
export interface ICodeBlockOptions {
|
|
27
|
+
/**
|
|
28
|
+
* The editor holding this code block
|
|
29
|
+
*/
|
|
24
30
|
ceEditor: CodeEditor.IEditor;
|
|
31
|
+
/**
|
|
32
|
+
* The value of code block
|
|
33
|
+
*/
|
|
25
34
|
value: string;
|
|
26
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Type of the cell holding this block
|
|
37
|
+
*/
|
|
38
|
+
type: string;
|
|
27
39
|
}
|
|
28
40
|
export interface IVirtualDocumentBlock {
|
|
29
41
|
/**
|
|
30
42
|
* Line corresponding to the block in the entire foreign document
|
|
31
43
|
*/
|
|
32
44
|
virtualLine: number;
|
|
45
|
+
/**
|
|
46
|
+
* The virtual document holding this virtual line.
|
|
47
|
+
*/
|
|
33
48
|
virtualDocument: VirtualDocument;
|
|
49
|
+
/**
|
|
50
|
+
* The CM editor associated with this virtual line.
|
|
51
|
+
*/
|
|
34
52
|
editor: CodeEditor.IEditor;
|
|
35
53
|
}
|
|
36
54
|
export declare type ForeignDocumentsMap = Map<IRange, IVirtualDocumentBlock>;
|
|
37
55
|
interface ISourceLine {
|
|
56
|
+
/**
|
|
57
|
+
* Line corresponding to the block in the entire foreign document
|
|
58
|
+
*/
|
|
38
59
|
virtualLine: number;
|
|
60
|
+
/**
|
|
61
|
+
* The CM editor associated with this virtual line.
|
|
62
|
+
*/
|
|
39
63
|
editor: CodeEditor.IEditor;
|
|
64
|
+
/**
|
|
65
|
+
* Line in the CM editor corresponding to the virtual line.
|
|
66
|
+
*/
|
|
40
67
|
editorLine: number;
|
|
68
|
+
/**
|
|
69
|
+
* Shift of the virtual line
|
|
70
|
+
*/
|
|
41
71
|
editorShift: CodeEditor.IPosition;
|
|
42
72
|
/**
|
|
43
73
|
* Everything which is not in the range of foreign documents belongs to the host.
|
|
@@ -45,7 +75,13 @@ interface ISourceLine {
|
|
|
45
75
|
foreignDocumentsMap: ForeignDocumentsMap;
|
|
46
76
|
}
|
|
47
77
|
export interface IForeignContext {
|
|
78
|
+
/**
|
|
79
|
+
* The virtual document
|
|
80
|
+
*/
|
|
48
81
|
foreignDocument: VirtualDocument;
|
|
82
|
+
/**
|
|
83
|
+
* The document holding the virtual document.
|
|
84
|
+
*/
|
|
49
85
|
parentHost: VirtualDocument;
|
|
50
86
|
}
|
|
51
87
|
/**
|
|
@@ -56,21 +92,55 @@ export interface IForeignContext {
|
|
|
56
92
|
*/
|
|
57
93
|
export declare function isWithinRange(position: CodeEditor.IPosition, range: CodeEditor.IRange): boolean;
|
|
58
94
|
/**
|
|
59
|
-
*
|
|
95
|
+
* A virtual implementation of IDocumentInfo
|
|
60
96
|
*/
|
|
61
97
|
export declare class VirtualDocumentInfo implements IDocumentInfo {
|
|
62
|
-
|
|
63
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Creates an instance of VirtualDocumentInfo.
|
|
100
|
+
* @param document - the virtual document need to
|
|
101
|
+
* be wrapped.
|
|
102
|
+
*/
|
|
64
103
|
constructor(document: VirtualDocument);
|
|
104
|
+
/**
|
|
105
|
+
* Current version of the virtual document.
|
|
106
|
+
*/
|
|
107
|
+
version: number;
|
|
108
|
+
/**
|
|
109
|
+
* Get the text content of the virtual document.
|
|
110
|
+
*/
|
|
65
111
|
get text(): string;
|
|
112
|
+
/**
|
|
113
|
+
* Get the uri of the virtual document, if the document is not available,
|
|
114
|
+
* it returns an empty string, users need to check for the length of returned
|
|
115
|
+
* value before using it.
|
|
116
|
+
*/
|
|
66
117
|
get uri(): string;
|
|
118
|
+
/**
|
|
119
|
+
* Get the language identifier of the document.
|
|
120
|
+
*/
|
|
67
121
|
get languageId(): string;
|
|
122
|
+
/**
|
|
123
|
+
* The wrapped virtual document.
|
|
124
|
+
*/
|
|
125
|
+
private _document;
|
|
68
126
|
}
|
|
69
127
|
export declare namespace VirtualDocument {
|
|
70
128
|
interface IOptions {
|
|
129
|
+
/**
|
|
130
|
+
* The language identifier of the document.
|
|
131
|
+
*/
|
|
71
132
|
language: LanguageIdentifier;
|
|
133
|
+
/**
|
|
134
|
+
* The foreign code extractor manager token.
|
|
135
|
+
*/
|
|
72
136
|
foreignCodeExtractors: ILSPCodeExtractorsManager;
|
|
137
|
+
/**
|
|
138
|
+
* Path to the document.
|
|
139
|
+
*/
|
|
73
140
|
path: string;
|
|
141
|
+
/**
|
|
142
|
+
* File extension of the document.
|
|
143
|
+
*/
|
|
74
144
|
fileExtension: string | undefined;
|
|
75
145
|
/**
|
|
76
146
|
* Notebooks or any other aggregates of documents are not supported
|
|
@@ -87,10 +157,14 @@ export declare namespace VirtualDocument {
|
|
|
87
157
|
*
|
|
88
158
|
*/
|
|
89
159
|
standalone?: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Parent of the current virtual document.
|
|
162
|
+
*/
|
|
90
163
|
parent?: VirtualDocument;
|
|
91
164
|
}
|
|
92
165
|
}
|
|
93
166
|
/**
|
|
167
|
+
*
|
|
94
168
|
* A notebook can hold one or more virtual documents; there is always one,
|
|
95
169
|
* "root" document, corresponding to the language of the kernel. All other
|
|
96
170
|
* virtual documents are extracted out of the notebook, based on magics,
|
|
@@ -110,101 +184,278 @@ export declare namespace VirtualDocument {
|
|
|
110
184
|
* No dependency on editor implementation (such as CodeMirrorEditor)
|
|
111
185
|
* is allowed for VirtualEditor.
|
|
112
186
|
*/
|
|
113
|
-
export declare class VirtualDocument {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
187
|
+
export declare class VirtualDocument implements IDisposable {
|
|
188
|
+
constructor(options: VirtualDocument.IOptions);
|
|
189
|
+
/**
|
|
190
|
+
* Convert from code editor position into code mirror position.
|
|
191
|
+
*/
|
|
192
|
+
static ceToCm(position: CodeEditor.IPosition): IPosition;
|
|
193
|
+
/**
|
|
194
|
+
* Number of blank lines appended to the virtual document between
|
|
195
|
+
* each cell.
|
|
196
|
+
*/
|
|
117
197
|
blankLinesBetweenCells: number;
|
|
198
|
+
/**
|
|
199
|
+
* Line number of the last line in the real document.
|
|
200
|
+
*/
|
|
118
201
|
lastSourceLine: number;
|
|
119
|
-
|
|
120
|
-
|
|
202
|
+
/**
|
|
203
|
+
* Line number of the last line in the virtual document.
|
|
204
|
+
*/
|
|
121
205
|
lastVirtualLine: number;
|
|
122
206
|
/**
|
|
123
207
|
* the remote document uri, version and other server-related info
|
|
124
208
|
*/
|
|
125
209
|
documentInfo: IDocumentInfo;
|
|
126
210
|
/**
|
|
127
|
-
*
|
|
211
|
+
* Parent of the current virtual document.
|
|
128
212
|
*/
|
|
129
|
-
virtualLines: Map<number, IVirtualLine>;
|
|
130
|
-
changed: Signal<VirtualDocument, VirtualDocument>;
|
|
131
|
-
path: string;
|
|
132
|
-
fileExtension: string | undefined;
|
|
133
|
-
hasLspSupportedFile: boolean;
|
|
134
213
|
parent?: VirtualDocument | null;
|
|
135
|
-
|
|
136
|
-
|
|
214
|
+
/**
|
|
215
|
+
* The language identifier of the document.
|
|
216
|
+
*/
|
|
217
|
+
readonly language: string;
|
|
218
|
+
/**
|
|
219
|
+
* Being standalone is relevant to foreign documents
|
|
220
|
+
* and defines whether following chunks of code in the same
|
|
221
|
+
* language should be appended to this document (false, not standalone)
|
|
222
|
+
* or should be considered separate documents (true, standalone)
|
|
223
|
+
*/
|
|
224
|
+
readonly standalone: boolean;
|
|
225
|
+
/**
|
|
226
|
+
* Path to the document.
|
|
227
|
+
*/
|
|
228
|
+
readonly path: string;
|
|
229
|
+
/**
|
|
230
|
+
* File extension of the document.
|
|
231
|
+
*/
|
|
232
|
+
readonly fileExtension: string | undefined;
|
|
233
|
+
/**
|
|
234
|
+
* Notebooks or any other aggregates of documents are not supported
|
|
235
|
+
* by the LSP specification, and we need to make appropriate
|
|
236
|
+
* adjustments for them, pretending they are simple files
|
|
237
|
+
* so that the LSP servers do not refuse to cooperate.
|
|
238
|
+
*/
|
|
239
|
+
readonly hasLspSupportedFile: boolean;
|
|
240
|
+
/**
|
|
241
|
+
* Map holding the children `VirtualDocument` .
|
|
242
|
+
*/
|
|
243
|
+
readonly foreignDocuments: Map<VirtualDocument.virtualId, VirtualDocument>;
|
|
244
|
+
/**
|
|
245
|
+
* The update manager object.
|
|
246
|
+
*/
|
|
247
|
+
readonly updateManager: UpdateManager;
|
|
248
|
+
/**
|
|
249
|
+
* Unique id of the virtual document.
|
|
250
|
+
*/
|
|
137
251
|
readonly instanceId: number;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
252
|
+
/**
|
|
253
|
+
* Test whether the document is disposed.
|
|
254
|
+
*/
|
|
255
|
+
get isDisposed(): boolean;
|
|
256
|
+
/**
|
|
257
|
+
* Signal emitted when the foreign document is closed
|
|
258
|
+
*/
|
|
259
|
+
get foreignDocumentClosed(): ISignal<VirtualDocument, IForeignContext>;
|
|
260
|
+
/**
|
|
261
|
+
* Signal emitted when the foreign document is opened
|
|
262
|
+
*/
|
|
263
|
+
get foreignDocumentOpened(): ISignal<VirtualDocument, IForeignContext>;
|
|
264
|
+
/**
|
|
265
|
+
* Signal emitted when the foreign document is changed
|
|
266
|
+
*/
|
|
267
|
+
get changed(): ISignal<VirtualDocument, VirtualDocument>;
|
|
268
|
+
/**
|
|
269
|
+
* Id of the virtual document.
|
|
270
|
+
*/
|
|
271
|
+
get virtualId(): VirtualDocument.virtualId;
|
|
272
|
+
/**
|
|
273
|
+
* Return the ancestry to this document.
|
|
274
|
+
*/
|
|
275
|
+
get ancestry(): Array<VirtualDocument>;
|
|
276
|
+
/**
|
|
277
|
+
* Return the id path to the virtual document.
|
|
278
|
+
*/
|
|
279
|
+
get idPath(): VirtualDocument.idPath;
|
|
280
|
+
/**
|
|
281
|
+
* Get the uri of the virtual document.
|
|
282
|
+
*/
|
|
283
|
+
get uri(): VirtualDocument.uri;
|
|
284
|
+
/**
|
|
285
|
+
* Get the text value of the document
|
|
286
|
+
*/
|
|
287
|
+
get value(): string;
|
|
288
|
+
/**
|
|
289
|
+
* Get the last line in the virtual document
|
|
290
|
+
*/
|
|
291
|
+
get lastLine(): string;
|
|
292
|
+
/**
|
|
293
|
+
* Get the root document of current virtual document.
|
|
294
|
+
*/
|
|
295
|
+
get root(): VirtualDocument;
|
|
296
|
+
/**
|
|
297
|
+
* Dispose the virtual document.
|
|
298
|
+
*/
|
|
150
299
|
dispose(): void;
|
|
151
300
|
/**
|
|
152
|
-
*
|
|
153
|
-
* This is meant to reduce the number of open connections when a a foreign code snippet was removed from the document.
|
|
154
|
-
*
|
|
155
|
-
* Note: top level virtual documents are currently immortal (unless killed by other means); it might be worth
|
|
156
|
-
* implementing culling of unused documents, but if and only if JupyterLab will also implement culling of
|
|
157
|
-
* idle kernels - otherwise the user experience could be a bit inconsistent, and we would need to invent our own rules.
|
|
301
|
+
* Clear the virtual document and all related stuffs
|
|
158
302
|
*/
|
|
159
|
-
protected get remainingLifetime(): number;
|
|
160
|
-
protected set remainingLifetime(value: number);
|
|
161
303
|
clear(): void;
|
|
304
|
+
/**
|
|
305
|
+
* Get the virtual document from the cursor position of the source
|
|
306
|
+
* document
|
|
307
|
+
* @param position - position in source document
|
|
308
|
+
*/
|
|
162
309
|
documentAtSourcePosition(position: ISourcePosition): VirtualDocument;
|
|
310
|
+
/**
|
|
311
|
+
* Detect if the input source position is belong to the current
|
|
312
|
+
* virtual document.
|
|
313
|
+
*
|
|
314
|
+
* @param sourcePosition - position in the source document
|
|
315
|
+
*/
|
|
163
316
|
isWithinForeign(sourcePosition: ISourcePosition): boolean;
|
|
317
|
+
/**
|
|
318
|
+
* Compute the position in root document from the position of
|
|
319
|
+
* a child editor.
|
|
320
|
+
*
|
|
321
|
+
* @param editor - the active editor.
|
|
322
|
+
* @param position - position in the active editor.
|
|
323
|
+
*/
|
|
164
324
|
transformFromEditorToRoot(editor: CodeEditor.IEditor, position: IEditorPosition): IRootPosition | null;
|
|
325
|
+
/**
|
|
326
|
+
* Compute the position in the virtual document from the position
|
|
327
|
+
* if the source document.
|
|
328
|
+
*
|
|
329
|
+
* @param sourcePosition - position in source document
|
|
330
|
+
*/
|
|
165
331
|
virtualPositionAtDocument(sourcePosition: ISourcePosition): IVirtualPosition;
|
|
332
|
+
/**
|
|
333
|
+
* Append a code block to the end of the virtual document.
|
|
334
|
+
*
|
|
335
|
+
* @param block - block to be appended
|
|
336
|
+
* @param editorShift - position shift in source
|
|
337
|
+
* document
|
|
338
|
+
* @param [virtualShift] - position shift in
|
|
339
|
+
* virtual document.
|
|
340
|
+
*/
|
|
166
341
|
appendCodeBlock(block: ICodeBlockOptions, editorShift?: CodeEditor.IPosition, virtualShift?: CodeEditor.IPosition): void;
|
|
342
|
+
/**
|
|
343
|
+
* Extract a code block into list of string in supported language and
|
|
344
|
+
* a map of foreign document if any.
|
|
345
|
+
* @param block - block to be appended
|
|
346
|
+
* @param editorShift - position shift in source document
|
|
347
|
+
*/
|
|
167
348
|
prepareCodeBlock(block: ICodeBlockOptions, editorShift?: CodeEditor.IPosition): {
|
|
168
349
|
lines: string[];
|
|
169
350
|
foreignDocumentsMap: Map<CodeEditor.IRange, IVirtualDocumentBlock>;
|
|
170
351
|
};
|
|
352
|
+
/**
|
|
353
|
+
* Extract the foreign code from input block by using the registered
|
|
354
|
+
* extractors.
|
|
355
|
+
* @param block - block to be appended
|
|
356
|
+
* @param editorShift - position shift in source document
|
|
357
|
+
*/
|
|
171
358
|
extractForeignCode(block: ICodeBlockOptions, editorShift: CodeEditor.IPosition): {
|
|
172
359
|
cellCodeKept: string;
|
|
173
360
|
foreignDocumentsMap: Map<CodeEditor.IRange, IVirtualDocumentBlock>;
|
|
174
361
|
};
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
private forwardOpenedSignal;
|
|
362
|
+
/**
|
|
363
|
+
* Close a foreign document and disconnect all associated signals
|
|
364
|
+
*/
|
|
179
365
|
closeForeign(document: VirtualDocument): void;
|
|
366
|
+
/**
|
|
367
|
+
* Close all foreign documents.
|
|
368
|
+
*/
|
|
180
369
|
closeAllForeignDocuments(): void;
|
|
181
|
-
|
|
182
|
-
|
|
370
|
+
/**
|
|
371
|
+
* Close all expired documents.
|
|
372
|
+
*/
|
|
183
373
|
closeExpiredDocuments(): void;
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
374
|
+
/**
|
|
375
|
+
* Transform the position of the source to the editor
|
|
376
|
+
* position.
|
|
377
|
+
*
|
|
378
|
+
* @param pos - position in the source document
|
|
379
|
+
* @return position in the editor.
|
|
380
|
+
*/
|
|
188
381
|
transformSourceToEditor(pos: ISourcePosition): IEditorPosition;
|
|
189
382
|
/**
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
383
|
+
* Transform the position in the virtual document to the
|
|
384
|
+
* editor position.
|
|
385
|
+
* Can be null because some lines are added as padding/anchors
|
|
386
|
+
* to the virtual document and those do not exist in the source document
|
|
387
|
+
* and thus they are absent in the editor.
|
|
388
|
+
*/
|
|
194
389
|
transformVirtualToEditor(virtualPosition: IVirtualPosition): IEditorPosition | null;
|
|
195
390
|
/**
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
391
|
+
* Transform the position in the virtual document to the source.
|
|
392
|
+
* Can be null because some lines are added as padding/anchors
|
|
393
|
+
* to the virtual document and those do not exist in the source document.
|
|
394
|
+
*/
|
|
199
395
|
transformVirtualToSource(position: IVirtualPosition): ISourcePosition | null;
|
|
200
|
-
|
|
396
|
+
/**
|
|
397
|
+
* Get the corresponding editor of the virtual line.
|
|
398
|
+
*/
|
|
201
399
|
getEditorAtVirtualLine(pos: IVirtualPosition): CodeEditor.IEditor;
|
|
400
|
+
/**
|
|
401
|
+
* Get the corresponding editor of the source line
|
|
402
|
+
*/
|
|
202
403
|
getEditorAtSourceLine(pos: ISourcePosition): CodeEditor.IEditor;
|
|
203
404
|
/**
|
|
204
405
|
* Recursively emits changed signal from the document or any descendant foreign document.
|
|
205
406
|
*/
|
|
206
407
|
maybeEmitChanged(): void;
|
|
207
|
-
|
|
408
|
+
/**
|
|
409
|
+
* When this counter goes down to 0, the document will be destroyed and the associated connection will be closed;
|
|
410
|
+
* This is meant to reduce the number of open connections when a a foreign code snippet was removed from the document.
|
|
411
|
+
*
|
|
412
|
+
* Note: top level virtual documents are currently immortal (unless killed by other means); it might be worth
|
|
413
|
+
* implementing culling of unused documents, but if and only if JupyterLab will also implement culling of
|
|
414
|
+
* idle kernels - otherwise the user experience could be a bit inconsistent, and we would need to invent our own rules.
|
|
415
|
+
*/
|
|
416
|
+
protected get remainingLifetime(): number;
|
|
417
|
+
protected set remainingLifetime(value: number);
|
|
418
|
+
/**
|
|
419
|
+
* Virtual lines keep all the lines present in the document AND extracted to the foreign document.
|
|
420
|
+
*/
|
|
421
|
+
protected virtualLines: Map<number, IVirtualLine>;
|
|
422
|
+
protected sourceLines: Map<number, ISourceLine>;
|
|
423
|
+
protected lineBlocks: Array<string>;
|
|
424
|
+
protected unusedDocuments: Set<VirtualDocument>;
|
|
425
|
+
protected unusedStandaloneDocuments: DefaultMap<language, Array<VirtualDocument>>;
|
|
426
|
+
private _isDisposed;
|
|
427
|
+
private _remainingLifetime;
|
|
428
|
+
private _editorToSourceLine;
|
|
429
|
+
private _editorToSourceLineNew;
|
|
430
|
+
private _foreignCodeExtractors;
|
|
431
|
+
private previousValue;
|
|
432
|
+
private static instancesCount;
|
|
433
|
+
private readonly options;
|
|
434
|
+
/**
|
|
435
|
+
* Get the foreign document that can be opened with the input extractor.
|
|
436
|
+
*/
|
|
437
|
+
private chooseForeignDocument;
|
|
438
|
+
/**
|
|
439
|
+
* Create a foreign document from input language and file extension.
|
|
440
|
+
*
|
|
441
|
+
* @param language - the required language
|
|
442
|
+
* @param standalone - the document type is supported natively by LSP?
|
|
443
|
+
* @param fileExtension - File extension.
|
|
444
|
+
*/
|
|
445
|
+
private openForeign;
|
|
446
|
+
/**
|
|
447
|
+
* Forward the closed signal from the foreign document to the host document's
|
|
448
|
+
* signal
|
|
449
|
+
*/
|
|
450
|
+
private forwardClosedSignal;
|
|
451
|
+
/**
|
|
452
|
+
* Forward the opened signal from the foreign document to the host document's
|
|
453
|
+
* signal
|
|
454
|
+
*/
|
|
455
|
+
private forwardOpenedSignal;
|
|
456
|
+
private _foreignDocumentClosed;
|
|
457
|
+
private _foreignDocumentOpened;
|
|
458
|
+
private _changed;
|
|
208
459
|
}
|
|
209
460
|
export declare namespace VirtualDocument {
|
|
210
461
|
/**
|
|
@@ -224,35 +475,54 @@ export declare namespace VirtualDocument {
|
|
|
224
475
|
*/
|
|
225
476
|
type uri = string;
|
|
226
477
|
}
|
|
478
|
+
/**
|
|
479
|
+
* Create foreign documents if available from input virtual documents.
|
|
480
|
+
* @param virtualDocument - the virtual document to be collected
|
|
481
|
+
* @return - Set of generated foreign documents
|
|
482
|
+
*/
|
|
227
483
|
export declare function collectDocuments(virtualDocument: VirtualDocument): Set<VirtualDocument>;
|
|
228
484
|
export interface IBlockAddedInfo {
|
|
485
|
+
/**
|
|
486
|
+
* The virtual document.
|
|
487
|
+
*/
|
|
229
488
|
virtualDocument: VirtualDocument;
|
|
489
|
+
/**
|
|
490
|
+
* Option of the code block.
|
|
491
|
+
*/
|
|
230
492
|
block: ICodeBlockOptions;
|
|
231
493
|
}
|
|
232
|
-
export declare class UpdateManager {
|
|
494
|
+
export declare class UpdateManager implements IDisposable {
|
|
233
495
|
private virtualDocument;
|
|
496
|
+
constructor(virtualDocument: VirtualDocument);
|
|
234
497
|
/**
|
|
235
|
-
*
|
|
498
|
+
* Promise resolved when the updating process finishes.
|
|
236
499
|
*/
|
|
237
|
-
|
|
238
|
-
private updateLock;
|
|
239
|
-
protected isDisposed: boolean;
|
|
500
|
+
get updateDone(): Promise<void>;
|
|
240
501
|
/**
|
|
241
|
-
*
|
|
502
|
+
* Test whether the document is disposed.
|
|
242
503
|
*/
|
|
243
|
-
|
|
244
|
-
blockAdded: Signal<UpdateManager, IBlockAddedInfo>;
|
|
245
|
-
updateDone: Promise<void>;
|
|
246
|
-
updateBegan: Signal<UpdateManager, ICodeBlockOptions[]>;
|
|
247
|
-
updateFinished: Signal<UpdateManager, ICodeBlockOptions[]>;
|
|
248
|
-
constructor(virtualDocument: VirtualDocument);
|
|
249
|
-
dispose(): void;
|
|
504
|
+
get isDisposed(): boolean;
|
|
250
505
|
/**
|
|
251
|
-
*
|
|
252
|
-
|
|
506
|
+
* Signal emitted when a code block is added to the document.
|
|
507
|
+
*/
|
|
508
|
+
get blockAdded(): ISignal<UpdateManager, IBlockAddedInfo>;
|
|
509
|
+
/**
|
|
510
|
+
* Signal emitted by the editor that triggered the update,
|
|
511
|
+
* providing the root document of the updated documents.
|
|
512
|
+
*/
|
|
513
|
+
get documentUpdated(): ISignal<UpdateManager, VirtualDocument>;
|
|
514
|
+
/**
|
|
515
|
+
* Signal emitted when the update is started
|
|
516
|
+
*/
|
|
517
|
+
get updateBegan(): ISignal<UpdateManager, ICodeBlockOptions[]>;
|
|
518
|
+
/**
|
|
519
|
+
* Signal emitted when the update is finished
|
|
520
|
+
*/
|
|
521
|
+
get updateFinished(): ISignal<UpdateManager, ICodeBlockOptions[]>;
|
|
522
|
+
/**
|
|
523
|
+
* Dispose the class
|
|
253
524
|
*/
|
|
254
|
-
|
|
255
|
-
private canUpdate;
|
|
525
|
+
dispose(): void;
|
|
256
526
|
/**
|
|
257
527
|
* Execute provided callback within an update-locked context, which guarantees that:
|
|
258
528
|
* - the previous updates must have finished before the callback call, and
|
|
@@ -266,5 +536,31 @@ export declare class UpdateManager {
|
|
|
266
536
|
* as to avoid an easy trap of ignoring the changes in the virtual documents.
|
|
267
537
|
*/
|
|
268
538
|
updateDocuments(blocks: ICodeBlockOptions[]): Promise<void>;
|
|
539
|
+
private _isDisposed;
|
|
540
|
+
/**
|
|
541
|
+
* Promise resolved when the updating process finishes.
|
|
542
|
+
*/
|
|
543
|
+
private _updateDone;
|
|
544
|
+
/**
|
|
545
|
+
* Virtual documents update guard.
|
|
546
|
+
*/
|
|
547
|
+
private _isUpdateInProgress;
|
|
548
|
+
/**
|
|
549
|
+
* Update lock to prevent multiple updates are applied at the same time.
|
|
550
|
+
*/
|
|
551
|
+
private _updateLock;
|
|
552
|
+
private _blockAdded;
|
|
553
|
+
private _documentUpdated;
|
|
554
|
+
private _updateBegan;
|
|
555
|
+
private _updateFinished;
|
|
556
|
+
/**
|
|
557
|
+
* Once all the foreign documents were refreshed, the unused documents (and their connections)
|
|
558
|
+
* should be terminated if their lifetime has expired.
|
|
559
|
+
*/
|
|
560
|
+
private _onUpdated;
|
|
561
|
+
/**
|
|
562
|
+
* Check if the document can be updated.
|
|
563
|
+
*/
|
|
564
|
+
private _canUpdate;
|
|
269
565
|
}
|
|
270
566
|
export {};
|