@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.
Files changed (65) hide show
  1. package/lib/adapters/adapter.d.ts +184 -54
  2. package/lib/adapters/adapter.js +177 -132
  3. package/lib/adapters/adapter.js.map +1 -1
  4. package/lib/adapters/statusmessage.d.ts +47 -0
  5. package/lib/adapters/statusmessage.js +74 -0
  6. package/lib/adapters/statusmessage.js.map +1 -0
  7. package/lib/connection.d.ts +113 -26
  8. package/lib/connection.js +166 -105
  9. package/lib/connection.js.map +1 -1
  10. package/lib/connection_manager.d.ts +143 -18
  11. package/lib/connection_manager.js +163 -49
  12. package/lib/connection_manager.js.map +1 -1
  13. package/lib/extractors/index.d.ts +3 -0
  14. package/lib/extractors/index.js +6 -0
  15. package/lib/extractors/index.js.map +1 -0
  16. package/lib/extractors/manager.d.ts +21 -4
  17. package/lib/extractors/manager.js +22 -5
  18. package/lib/extractors/manager.js.map +1 -1
  19. package/lib/extractors/text_extractor.d.ts +34 -7
  20. package/lib/extractors/text_extractor.js +11 -0
  21. package/lib/extractors/text_extractor.js.map +1 -1
  22. package/lib/extractors/types.d.ts +8 -6
  23. package/lib/extractors/types.js +2 -0
  24. package/lib/extractors/types.js.map +1 -1
  25. package/lib/feature.d.ts +18 -3
  26. package/lib/feature.js +20 -3
  27. package/lib/feature.js.map +1 -1
  28. package/lib/index.d.ts +6 -9
  29. package/lib/index.js +8 -13
  30. package/lib/index.js.map +1 -1
  31. package/lib/lsp.d.ts +10 -4
  32. package/lib/lsp.js +2 -0
  33. package/lib/lsp.js.map +1 -1
  34. package/lib/manager.d.ts +103 -16
  35. package/lib/manager.js +118 -31
  36. package/lib/manager.js.map +1 -1
  37. package/lib/plugin.d.ts +18 -13
  38. package/lib/plugin.js +2 -1
  39. package/lib/plugin.js.map +1 -1
  40. package/lib/positioning.d.ts +43 -6
  41. package/lib/positioning.js +28 -2
  42. package/lib/positioning.js.map +1 -1
  43. package/lib/schema.js +2 -1
  44. package/lib/schema.js.map +1 -1
  45. package/lib/tokens.d.ts +275 -45
  46. package/lib/tokens.js +28 -0
  47. package/lib/tokens.js.map +1 -1
  48. package/lib/utils.d.ts +15 -1
  49. package/lib/utils.js +18 -2
  50. package/lib/utils.js.map +1 -1
  51. package/lib/virtual/document.d.ts +374 -78
  52. package/lib/virtual/document.js +375 -148
  53. package/lib/virtual/document.js.map +1 -1
  54. package/lib/ws-connection/server-capability-registration.d.ts +18 -0
  55. package/lib/ws-connection/server-capability-registration.js +46 -0
  56. package/lib/ws-connection/server-capability-registration.js.map +1 -0
  57. package/lib/ws-connection/types.d.ts +75 -0
  58. package/lib/ws-connection/types.js +7 -0
  59. package/lib/ws-connection/types.js.map +1 -0
  60. package/lib/ws-connection/ws-connection.d.ts +82 -0
  61. package/lib/ws-connection/ws-connection.js +201 -0
  62. package/lib/ws-connection/ws-connection.js.map +1 -0
  63. package/package.json +15 -16
  64. package/style/index.css +0 -2
  65. package/style/index.js +0 -2
@@ -1,40 +1,34 @@
1
- import { JupyterFrontEnd } from '@jupyterlab/application';
1
+ import { IDisposable } from '@lumino/disposable';
2
2
  import { CodeEditor } from '@jupyterlab/codeeditor';
3
3
  import { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry';
4
- import * as nbformat from '@jupyterlab/nbformat';
5
4
  import { ITranslator, TranslationBundle } from '@jupyterlab/translation';
6
- import { Signal } from '@lumino/signaling';
5
+ import { ISignal, Signal } from '@lumino/signaling';
7
6
  import { LanguageIdentifier } from '../lsp';
8
7
  import { IVirtualPosition } from '../positioning';
9
8
  import { IDocumentConnectionData, ILSPCodeExtractorsManager, ILSPDocumentConnectionManager, ILSPFeatureManager } from '../tokens';
10
9
  import { IForeignContext, VirtualDocument } from '../virtual/document';
11
- export declare class StatusMessage {
12
- /**
13
- * The text message to be shown on the statusbar
14
- */
15
- message: string;
16
- changed: Signal<StatusMessage, void>;
17
- private timer;
18
- constructor();
10
+ export interface IEditorChangedData {
19
11
  /**
20
- * Set the text message and (optionally) the timeout to remove it.
21
- * @param message
22
- * @param timeout - number of ms to until the message is cleaned;
23
- * -1 if the message should stay up indefinitely;
24
- * defaults to 3000ms (3 seconds)
12
+ * The CM editor invoking the change event.
25
13
  */
26
- set(message: string, timeout?: number): void;
27
- clear(): void;
28
- private expireTimer;
29
- }
30
- export interface IEditorChangedData {
31
14
  editor: CodeEditor.IEditor;
32
15
  }
33
16
  export interface IAdapterOptions {
34
- app: JupyterFrontEnd;
17
+ /**
18
+ * The LSP document and connection manager instance.
19
+ */
35
20
  connectionManager: ILSPDocumentConnectionManager;
21
+ /**
22
+ * The LSP feature manager instance.
23
+ */
36
24
  featureManager: ILSPFeatureManager;
25
+ /**
26
+ * The LSP foreign code extractor manager.
27
+ */
37
28
  foreignCodeExtractorsManager: ILSPCodeExtractorsManager;
29
+ /**
30
+ * The translator provider.
31
+ */
38
32
  translator?: ITranslator;
39
33
  }
40
34
  /**
@@ -43,49 +37,152 @@ export interface IAdapterOptions {
43
37
  * as this would make the logic of inspections caching impossible to maintain, thus the WidgetAdapter
44
38
  * has to handle that, keeping multiple connections and multiple virtual documents.
45
39
  */
46
- export declare abstract class WidgetAdapter<T extends IDocumentWidget> {
47
- protected options: IAdapterOptions;
40
+ export declare abstract class WidgetLSPAdapter<T extends IDocumentWidget> implements IDisposable {
48
41
  widget: T;
49
- adapterConnected: Signal<WidgetAdapter<T>, IDocumentConnectionData>;
42
+ protected options: IAdapterOptions;
43
+ constructor(widget: T, options: IAdapterOptions);
44
+ /**
45
+ * Check if the adapter is disposed
46
+ */
47
+ get isDisposed(): boolean;
48
+ /**
49
+ * Check if the document contains multiple editors
50
+ */
51
+ get hasMultipleEditors(): boolean;
52
+ /**
53
+ * Get the ID of the internal widget.
54
+ */
55
+ get widgetId(): string;
56
+ /**
57
+ * Get the language identifier of the document
58
+ */
59
+ get language(): LanguageIdentifier;
60
+ /**
61
+ * Signal emitted when the adapter is connected.
62
+ */
63
+ get adapterConnected(): ISignal<WidgetLSPAdapter<T>, IDocumentConnectionData>;
64
+ /**
65
+ * Signal emitted when the active editor have changed.
66
+ */
67
+ get activeEditorChanged(): ISignal<WidgetLSPAdapter<T>, IEditorChangedData>;
68
+ /**
69
+ * Signal emitted when the adapter is disposed.
70
+ */
71
+ get disposed(): ISignal<WidgetLSPAdapter<T>, void>;
72
+ /**
73
+ * Signal emitted when the an editor is changed.
74
+ */
75
+ get editorAdded(): ISignal<WidgetLSPAdapter<T>, IEditorChangedData>;
76
+ /**
77
+ * Signal emitted when the an editor is removed.
78
+ */
79
+ get editorRemoved(): ISignal<WidgetLSPAdapter<T>, IEditorChangedData>;
80
+ /**
81
+ * Get the inner HTMLElement of the document widget.
82
+ */
83
+ abstract get wrapperElement(): HTMLElement;
84
+ /**
85
+ * Get current path of the document.
86
+ */
87
+ abstract get documentPath(): string;
88
+ /**
89
+ * Get the mime type of the document.
90
+ */
91
+ abstract get mimeType(): string;
92
+ /**
93
+ * Get the file extension of the document.
94
+ */
95
+ abstract get languageFileExtension(): string | undefined;
96
+ /**
97
+ * Get the activated CM editor.
98
+ */
99
+ abstract get activeEditor(): CodeEditor.IEditor | undefined;
100
+ /**
101
+ * Get the list of CM editors in the document, there is only one editor
102
+ * in the case of file editor.
103
+ */
104
+ abstract get editors(): {
105
+ ceEditor: CodeEditor.IEditor;
106
+ type: string;
107
+ }[];
108
+ /**
109
+ * The virtual document is connected or not
110
+ */
50
111
  isConnected: boolean;
112
+ /**
113
+ * The LSP document and connection manager instance.
114
+ */
51
115
  connectionManager: ILSPDocumentConnectionManager;
116
+ /**
117
+ * The translator provider.
118
+ */
52
119
  trans: TranslationBundle;
53
- protected isDisposed: boolean;
54
- protected app: JupyterFrontEnd;
55
- activeEditorChanged: Signal<WidgetAdapter<T>, IEditorChangedData>;
56
- editorAdded: Signal<WidgetAdapter<T>, IEditorChangedData>;
57
- editorRemoved: Signal<WidgetAdapter<T>, IEditorChangedData>;
120
+ /**
121
+ * Promise that resolves once the document is updated
122
+ */
58
123
  updateFinished: Promise<void>;
59
- initialized: Promise<void>;
124
+ /**
125
+ * Promise that resolves once the adapter is initialized
126
+ */
127
+ ready: Promise<void>;
128
+ /**
129
+ * Internal virtual document of the adapter.
130
+ */
60
131
  virtualDocument: VirtualDocument;
132
+ /**
133
+ * Callback on connection closed event.
134
+ */
135
+ onConnectionClosed(_: ILSPDocumentConnectionManager, { virtualDocument }: IDocumentConnectionData): void;
136
+ /**
137
+ * Dispose the adapter.
138
+ */
139
+ dispose(): void;
140
+ /**
141
+ * Disconnect virtual document from the language server.
142
+ */
143
+ disconnect(): void;
144
+ /**
145
+ * Update the virtual document.
146
+ */
147
+ updateDocuments(): Promise<void>;
148
+ /**
149
+ * Callback called on the document changed event.
150
+ */
151
+ documentChanged(virtualDocument: VirtualDocument, document: VirtualDocument, isInit?: boolean): void;
61
152
  /**
62
153
  * (re)create virtual document using current path and language
63
154
  */
64
155
  abstract createVirtualDocument(): VirtualDocument;
156
+ /**
157
+ * Get the index of editor from the cursor position in the virtual
158
+ * document. Since there is only one editor, this method always return
159
+ * 0
160
+ *
161
+ * @param position - the position of cursor in the virtual document.
162
+ * @return - index of the virtual editor
163
+ */
65
164
  abstract getEditorIndexAt(position: IVirtualPosition): number;
165
+ /**
166
+ * Get the index of input editor
167
+ *
168
+ * @param ceEditor - instance of the code editor
169
+ */
66
170
  abstract getEditorIndex(ceEditor: CodeEditor.IEditor): number;
171
+ /**
172
+ * Get the wrapper of input editor.
173
+ *
174
+ * @param ceEditor
175
+ */
67
176
  abstract getEditorWrapper(ceEditor: CodeEditor.IEditor): HTMLElement;
68
- protected constructor(options: IAdapterOptions, widget: T);
69
- onConnectionClosed(_: ILSPDocumentConnectionManager, { virtualDocument }: IDocumentConnectionData): void;
70
- dispose(): void;
71
- abstract get documentPath(): string;
72
- abstract get mimeType(): string;
73
- get widgetId(): string;
74
- get language(): LanguageIdentifier;
75
- abstract get languageFileExtension(): string | undefined;
76
- disconnect(): void;
77
177
  protected reloadConnection(): void;
178
+ /**
179
+ * Callback on document saved event.
180
+ */
78
181
  protected onSaveState(context: DocumentRegistry.IContext<DocumentRegistry.IModel>, state: DocumentRegistry.SaveState): void;
79
- abstract activeEditor: CodeEditor.IEditor | undefined;
80
- abstract get editors(): {
81
- ceEditor: CodeEditor.IEditor;
82
- type: nbformat.CellType;
83
- }[];
182
+ protected _isDisposed: boolean;
84
183
  /**
85
- * public for use in tests (but otherwise could be private)
184
+ * Connect the virtual document with the language server.
86
185
  */
87
- updateDocuments(): Promise<void> | undefined;
88
- get hasMultipleEditors(): boolean;
89
186
  protected onConnected(data: IDocumentConnectionData): Promise<void>;
90
187
  /**
91
188
  * Opens a connection for the document. The connection may or may
@@ -96,8 +193,10 @@ export declare abstract class WidgetAdapter<T extends IDocumentWidget> {
96
193
  * @param sendOpen whether to open the document immediately
97
194
  */
98
195
  protected connectDocument(virtualDocument: VirtualDocument, sendOpen?: boolean): Promise<void>;
196
+ /**
197
+ * Create the virtual document using current path and language.
198
+ */
99
199
  protected initVirtual(): void;
100
- private onForeignDocumentClosed;
101
200
  /**
102
201
  * Handler for opening a document contained in a parent document. The assumption
103
202
  * is that the editor already exists for this, and as such the document
@@ -107,8 +206,37 @@ export declare abstract class WidgetAdapter<T extends IDocumentWidget> {
107
206
  * @param context information about the foreign VirtualDocument
108
207
  */
109
208
  protected onForeignDocumentOpened(_: VirtualDocument, context: IForeignContext): Promise<void>;
110
- documentChanged(virtualDocument: VirtualDocument, document: VirtualDocument, isInit?: boolean): void;
111
- private connect;
209
+ /**
210
+ * Signal emitted when the adapter is connected.
211
+ */
212
+ protected _adapterConnected: Signal<WidgetLSPAdapter<T>, IDocumentConnectionData>;
213
+ /**
214
+ * Signal emitted when the active editor have changed.
215
+ */
216
+ protected _activeEditorChanged: Signal<WidgetLSPAdapter<T>, IEditorChangedData>;
217
+ /**
218
+ * Signal emitted when an editor is changed.
219
+ */
220
+ protected _editorAdded: Signal<WidgetLSPAdapter<T>, IEditorChangedData>;
221
+ /**
222
+ * Signal emitted when an editor is removed.
223
+ */
224
+ protected _editorRemoved: Signal<WidgetLSPAdapter<T>, IEditorChangedData>;
225
+ /**
226
+ * Signal emitted when the adapter is disposed.
227
+ */
228
+ protected _disposed: Signal<WidgetLSPAdapter<T>, void>;
229
+ /**
230
+ * Callback called when a foreign document is closed,
231
+ * the associated signals with this virtual document
232
+ * are disconnected.
233
+ */
234
+ private _onForeignDocumentClosed;
235
+ /**
236
+ * Detect the capabilities for the document type then
237
+ * open the websocket connection with the language server.
238
+ */
239
+ private _connect;
112
240
  /**
113
241
  * Connect the change signal in order to update all virtual documents after a change.
114
242
  *
@@ -119,7 +247,9 @@ export declare abstract class WidgetAdapter<T extends IDocumentWidget> {
119
247
  * (range) updates this can be still implemented by comparison of before/after states of the
120
248
  * virtual documents, which is even more resilient and -obviously - editor-independent.
121
249
  */
122
- private connectContentChangedSignal;
123
- private onContentChanged;
124
- abstract get wrapperElement(): HTMLElement;
250
+ private _connectContentChangedSignal;
251
+ /**
252
+ * Callback called when the content of the document have changed.
253
+ */
254
+ private _onContentChanged;
125
255
  }