@lvce-editor/extension-host-worker 1.1.0 → 1.2.1
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/dist/extensionHostWorkerMain.js +1257 -60
- package/package.json +1 -1
|
@@ -4,13 +4,13 @@ const Function = 3;
|
|
|
4
4
|
const Variable = 4;
|
|
5
5
|
const Keyword = 5;
|
|
6
6
|
const Folder = 6;
|
|
7
|
-
const File$
|
|
7
|
+
const File$2 = 7;
|
|
8
8
|
const Field = 8;
|
|
9
9
|
|
|
10
10
|
const EditorCompletionType = {
|
|
11
11
|
__proto__: null,
|
|
12
12
|
Field,
|
|
13
|
-
File: File$
|
|
13
|
+
File: File$2,
|
|
14
14
|
Folder,
|
|
15
15
|
Function,
|
|
16
16
|
Keyword,
|
|
@@ -64,6 +64,18 @@ const object = value => {
|
|
|
64
64
|
throw new AssertionError$1('expected value to be of type object');
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
|
+
const number$1 = value => {
|
|
68
|
+
const type = getType$3(value);
|
|
69
|
+
if (type !== 'number') {
|
|
70
|
+
throw new AssertionError$1('expected value to be of type number');
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const array = value => {
|
|
74
|
+
const type = getType$3(value);
|
|
75
|
+
if (type !== 'array') {
|
|
76
|
+
throw new AssertionError$1('expected value to be of type array');
|
|
77
|
+
}
|
|
78
|
+
};
|
|
67
79
|
const string = value => {
|
|
68
80
|
const type = getType$3(value);
|
|
69
81
|
if (type !== 'string') {
|
|
@@ -77,7 +89,7 @@ const fn = value => {
|
|
|
77
89
|
}
|
|
78
90
|
};
|
|
79
91
|
|
|
80
|
-
const state$
|
|
92
|
+
const state$b = {
|
|
81
93
|
/** @type{any[]} */
|
|
82
94
|
onDidOpenEditorListeners: [],
|
|
83
95
|
/** @type{any[]} */
|
|
@@ -88,10 +100,209 @@ const state$a = {
|
|
|
88
100
|
onDidSaveTextDocumentListeners: [],
|
|
89
101
|
textDocuments: Object.create(null)
|
|
90
102
|
};
|
|
103
|
+
const setDocument = (textDocumentId, textDocument) => {
|
|
104
|
+
state$b.textDocuments[textDocumentId] = textDocument;
|
|
105
|
+
};
|
|
106
|
+
const getDidOpenListeners = () => {
|
|
107
|
+
return state$b.onDidSaveTextDocumentListeners;
|
|
108
|
+
};
|
|
109
|
+
const getWillChangeListeners = () => {
|
|
110
|
+
return state$b.onWillChangeEditorListeners;
|
|
111
|
+
};
|
|
112
|
+
const getDidChangeListeners = () => {
|
|
113
|
+
return state$b.onDidChangeTextDocumentListeners;
|
|
114
|
+
};
|
|
91
115
|
const getDocument = textDocumentId => {
|
|
92
|
-
return state$
|
|
116
|
+
return state$b.textDocuments[textDocumentId];
|
|
93
117
|
};
|
|
94
118
|
|
|
119
|
+
const getOffset$1 = (textDocument, position) => {
|
|
120
|
+
let offset = 0;
|
|
121
|
+
let rowIndex = 0;
|
|
122
|
+
while (rowIndex++ < position.rowIndex) {
|
|
123
|
+
const newLineIndex = textDocument.text.indexOf('\n', offset);
|
|
124
|
+
offset = newLineIndex + 1;
|
|
125
|
+
}
|
|
126
|
+
offset += position.columnIndex;
|
|
127
|
+
return offset;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// const toOffsetBasedEdit = (textDocument, documentEdit) => {
|
|
131
|
+
// switch (documentEdit.type) {
|
|
132
|
+
// case /* singleLineEdit */ 1: {
|
|
133
|
+
// const offset = getOffset(textDocument, documentEdit)
|
|
134
|
+
// return {
|
|
135
|
+
// offset,
|
|
136
|
+
// inserted: documentEdit.inserted,
|
|
137
|
+
// deleted: documentEdit.deleted,
|
|
138
|
+
// // type: /* singleLineEdit */ 1
|
|
139
|
+
// }
|
|
140
|
+
// }
|
|
141
|
+
// case /* splice */ 2:
|
|
142
|
+
// const offset = getOffset(textDocument, {
|
|
143
|
+
// rowIndex: documentEdit.rowIndex,
|
|
144
|
+
// columnIndex: textDocument.lines[documentEdit.rowIndex - 1].length,
|
|
145
|
+
// })
|
|
146
|
+
// const inserted = '\n' + documentEdit.newLines.join('\n')
|
|
147
|
+
// return {
|
|
148
|
+
// offset,
|
|
149
|
+
// inserted,
|
|
150
|
+
// deleted: 0 /* TODO */,
|
|
151
|
+
// }
|
|
152
|
+
// }
|
|
153
|
+
// }
|
|
154
|
+
|
|
155
|
+
// TODO incremental edits, don't send full text
|
|
156
|
+
// export const applyEdit = (id, text, edits) => {
|
|
157
|
+
// const textDocument = get(id)
|
|
158
|
+
// textDocument.lines = text.split('\n')
|
|
159
|
+
// const offsetBasedEdits = edits.map((edit) =>
|
|
160
|
+
// toOffsetBasedEdit(textDocument, edit)
|
|
161
|
+
// )
|
|
162
|
+
// for (const listener of state.onDidChangeTextDocumentListeners) {
|
|
163
|
+
// // TODO avoid extra object allocation
|
|
164
|
+
// listener(textDocument, offsetBasedEdits)
|
|
165
|
+
// }
|
|
166
|
+
// }
|
|
167
|
+
|
|
168
|
+
// TODO data oriented vs object oriented
|
|
169
|
+
// data -> simpler, exposes internals, sometimes weird/long (vscode.TextDocument.getText(textDocument))
|
|
170
|
+
// object oriented -> hides internals, banana problem (textDocument.getText())
|
|
171
|
+
|
|
172
|
+
// TODO send to shared process, which sends it to renderer worker
|
|
173
|
+
// renderer worker sends back the edit
|
|
174
|
+
// export const applyEdit2 = (textDocument, edit) => {
|
|
175
|
+
// if (VALIDATION_ENABLED) {
|
|
176
|
+
// assert(typeof textDocument === 'object')
|
|
177
|
+
// assert(textDocument !== null)
|
|
178
|
+
// assert(typeof textDocument.id === 'number')
|
|
179
|
+
// assert(textDocument.id > 0)
|
|
180
|
+
// assert(typeof textDocument.getText === 'function')
|
|
181
|
+
// assert(typeof edit === 'object')
|
|
182
|
+
// assert(typeof edit.offset === 'number')
|
|
183
|
+
// assert(typeof edit.inserted === 'string')
|
|
184
|
+
// assert(typeof edit.deleted === 'number')
|
|
185
|
+
// }
|
|
186
|
+
|
|
187
|
+
// let rowIndex = 0
|
|
188
|
+
// let offset = 0
|
|
189
|
+
// const lines = textDocument.getText().split('\n')
|
|
190
|
+
// while (offset < edit.offset) {
|
|
191
|
+
// offset += lines[rowIndex++].length + 1
|
|
192
|
+
// }
|
|
193
|
+
// rowIndex--
|
|
194
|
+
// offset -= lines[rowIndex].length + 1
|
|
195
|
+
// const edit2 = {
|
|
196
|
+
// rowIndex,
|
|
197
|
+
// inserted: edit.inserted,
|
|
198
|
+
// deleted: edit.deleted,
|
|
199
|
+
// columnIndex: edit.offset - offset + edit.deleted,
|
|
200
|
+
// type: 1,
|
|
201
|
+
// }
|
|
202
|
+
|
|
203
|
+
// // // TODO should be invoke and return boolean whether edit was applied or not
|
|
204
|
+
// SharedProcess.send({
|
|
205
|
+
// event: 'TextDocument.applyEdit',
|
|
206
|
+
// args: [/* id */ textDocument.id, /* edits */ edit2],
|
|
207
|
+
// })
|
|
208
|
+
// }
|
|
209
|
+
|
|
210
|
+
// export const create = (textDocumentId, languageId, content) => {
|
|
211
|
+
// const textDocument = {
|
|
212
|
+
// languageId,
|
|
213
|
+
// lines: content.split('\n'),
|
|
214
|
+
// }
|
|
215
|
+
// state.textDocuments[textDocumentId] = textDocument
|
|
216
|
+
// }
|
|
217
|
+
|
|
218
|
+
// const createTextDocument = (uri, languageId, text) => {
|
|
219
|
+
// if (VALIDATION_ENABLED) {
|
|
220
|
+
// assert(typeof uri === 'string')
|
|
221
|
+
// assert(typeof languageId === 'string')
|
|
222
|
+
// assert(typeof text === 'string')
|
|
223
|
+
// }
|
|
224
|
+
// const state = {
|
|
225
|
+
// /** @internal */
|
|
226
|
+
// lines: text.split('\n'),
|
|
227
|
+
// uri,
|
|
228
|
+
// languageId,
|
|
229
|
+
// getText() {
|
|
230
|
+
// return state.lines.join('\n')
|
|
231
|
+
// },
|
|
232
|
+
// }
|
|
233
|
+
// return state
|
|
234
|
+
// }
|
|
235
|
+
|
|
236
|
+
// export const sync = (documentId, languageId, text) => {
|
|
237
|
+
// const textDocument = get(documentId)
|
|
238
|
+
// if (!textDocument) {
|
|
239
|
+
// console.warn(`textDocument is undefined ${languageId}`)
|
|
240
|
+
// return
|
|
241
|
+
// }
|
|
242
|
+
// textDocument.languageId = languageId
|
|
243
|
+
// textDocument.lines = text.split('\n')
|
|
244
|
+
// // console.log('sync', JSON.stringify(text))
|
|
245
|
+
// }
|
|
246
|
+
|
|
247
|
+
const runListenerSafe = async (listener, ...args) => {
|
|
248
|
+
try {
|
|
249
|
+
await listener(...args);
|
|
250
|
+
} catch (error) {
|
|
251
|
+
// @ts-ignore
|
|
252
|
+
if (error && error.message) {
|
|
253
|
+
// @ts-ignore
|
|
254
|
+
error.message = 'Failed to run open listener: ' + error.message;
|
|
255
|
+
}
|
|
256
|
+
console.error(error);
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
const runListenersSafe = (listeners, ...args) => {
|
|
260
|
+
for (const listener of listeners) {
|
|
261
|
+
runListenerSafe(listener, ...args);
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
const syncFull = (uri, textDocumentId, languageId, text) => {
|
|
265
|
+
const textDocument = {
|
|
266
|
+
uri,
|
|
267
|
+
documentId: textDocumentId,
|
|
268
|
+
languageId,
|
|
269
|
+
text
|
|
270
|
+
};
|
|
271
|
+
setDocument(textDocumentId, textDocument);
|
|
272
|
+
runListenersSafe(getDidOpenListeners(), textDocument);
|
|
273
|
+
};
|
|
274
|
+
const getSyntheticChanges = (textDocument, changes) => {
|
|
275
|
+
// console.log({ textDocument, changes })
|
|
276
|
+
object(textDocument);
|
|
277
|
+
array(changes);
|
|
278
|
+
const change = changes[0];
|
|
279
|
+
const startOffset = getOffset$1(textDocument, change.start);
|
|
280
|
+
const endOffset = getOffset$1(textDocument, change.end);
|
|
281
|
+
const inserted = change.inserted.join('\n');
|
|
282
|
+
const syntheticChanges = [{
|
|
283
|
+
startOffset,
|
|
284
|
+
endOffset,
|
|
285
|
+
inserted
|
|
286
|
+
}];
|
|
287
|
+
return syntheticChanges;
|
|
288
|
+
};
|
|
289
|
+
const syncIncremental = (textDocumentId, changes) => {
|
|
290
|
+
number$1(textDocumentId);
|
|
291
|
+
array(changes);
|
|
292
|
+
const textDocument = getDocument(textDocumentId);
|
|
293
|
+
if (!textDocument) {
|
|
294
|
+
console.warn(`sync not possible, no matching textDocument with id ${textDocumentId}`);
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
const syntheticChanges = getSyntheticChanges(textDocument, changes);
|
|
298
|
+
runListenersSafe(getWillChangeListeners(), textDocument, syntheticChanges);
|
|
299
|
+
const syntheticChange = syntheticChanges[0];
|
|
300
|
+
const oldText = textDocument.text;
|
|
301
|
+
const before = oldText.slice(0, syntheticChange.startOffset);
|
|
302
|
+
const after = oldText.slice(syntheticChange.endOffset);
|
|
303
|
+
textDocument.text = before + syntheticChange.inserted + after;
|
|
304
|
+
runListenersSafe(getDidChangeListeners(), textDocument, syntheticChanges);
|
|
305
|
+
};
|
|
95
306
|
const get$3 = textDocumentId => {
|
|
96
307
|
const textDocument = getDocument(textDocumentId);
|
|
97
308
|
return textDocument;
|
|
@@ -99,7 +310,16 @@ const get$3 = textDocumentId => {
|
|
|
99
310
|
const getText = textDocument => {
|
|
100
311
|
return textDocument.text;
|
|
101
312
|
};
|
|
313
|
+
const setLanguageId = (textDocumentId, languageId) => {
|
|
314
|
+
const newTextDocument = {
|
|
315
|
+
...getDocument(textDocumentId),
|
|
316
|
+
languageId
|
|
317
|
+
};
|
|
318
|
+
setDocument(textDocumentId, newTextDocument);
|
|
319
|
+
runListenersSafe(getDidOpenListeners(), newTextDocument);
|
|
320
|
+
};
|
|
102
321
|
|
|
322
|
+
const BABEL_PARSER_SYNTAX_ERROR = 'BABEL_PARSER_SYNTAX_ERROR';
|
|
103
323
|
const E_COMMAND_NOT_FOUND$1 = 'E_COMMAND_NOT_FOUND';
|
|
104
324
|
const E_NO_PROVIDER_FOUND = 'E_NO_PROVIDER_FOUND';
|
|
105
325
|
|
|
@@ -352,7 +572,7 @@ const registerMethod = ({
|
|
|
352
572
|
}
|
|
353
573
|
};
|
|
354
574
|
};
|
|
355
|
-
const create$
|
|
575
|
+
const create$9 = ({
|
|
356
576
|
name,
|
|
357
577
|
resultShape,
|
|
358
578
|
executeKey = '',
|
|
@@ -404,7 +624,7 @@ const {
|
|
|
404
624
|
registerBraceCompletionProvider,
|
|
405
625
|
executeBraceCompletionProvider,
|
|
406
626
|
reset: reset$9
|
|
407
|
-
} = create$
|
|
627
|
+
} = create$9({
|
|
408
628
|
name: 'BraceCompletion',
|
|
409
629
|
resultShape: {
|
|
410
630
|
type: Boolean
|
|
@@ -414,7 +634,7 @@ const {
|
|
|
414
634
|
const {
|
|
415
635
|
registerClosingTagProvider,
|
|
416
636
|
executeClosingTagProvider
|
|
417
|
-
} = create$
|
|
637
|
+
} = create$9({
|
|
418
638
|
name: 'ClosingTag',
|
|
419
639
|
returnUndefinedWhenNoProviderFound: true,
|
|
420
640
|
resultShape: {
|
|
@@ -426,7 +646,7 @@ const {
|
|
|
426
646
|
const {
|
|
427
647
|
registerCodeActionProvider,
|
|
428
648
|
executeCodeActionProvider
|
|
429
|
-
} = create$
|
|
649
|
+
} = create$9({
|
|
430
650
|
name: 'CodeAction',
|
|
431
651
|
resultShape: {
|
|
432
652
|
type: Array$1,
|
|
@@ -435,8 +655,28 @@ const {
|
|
|
435
655
|
}
|
|
436
656
|
}
|
|
437
657
|
});
|
|
658
|
+
const isOrganizeImports = action => {
|
|
659
|
+
return action.kind === 'source.organizeImports';
|
|
660
|
+
};
|
|
438
661
|
|
|
439
|
-
|
|
662
|
+
// TODO handle case when multiple organize imports providers are registered
|
|
663
|
+
const executeOrganizeImports = async uid => {
|
|
664
|
+
const actions = await executeCodeActionProvider(uid);
|
|
665
|
+
// @ts-ignore
|
|
666
|
+
if (!actions || actions.length === 0) {
|
|
667
|
+
return [];
|
|
668
|
+
}
|
|
669
|
+
// @ts-ignore
|
|
670
|
+
const organizeImportsAction = actions.find(isOrganizeImports);
|
|
671
|
+
if (!organizeImportsAction) {
|
|
672
|
+
return [];
|
|
673
|
+
}
|
|
674
|
+
const textDocument = get$3(uid);
|
|
675
|
+
const edits = await organizeImportsAction.execute(textDocument);
|
|
676
|
+
return edits;
|
|
677
|
+
};
|
|
678
|
+
|
|
679
|
+
const state$a = {
|
|
440
680
|
commands: Object.create(null)
|
|
441
681
|
};
|
|
442
682
|
const getCommandDisplay = command => {
|
|
@@ -459,10 +699,10 @@ const registerCommand = command => {
|
|
|
459
699
|
if (!command.execute) {
|
|
460
700
|
throw new Error('command is missing execute function');
|
|
461
701
|
}
|
|
462
|
-
if (command.id in state$
|
|
702
|
+
if (command.id in state$a.commands) {
|
|
463
703
|
throw new Error(`command cannot be registered multiple times`);
|
|
464
704
|
}
|
|
465
|
-
state$
|
|
705
|
+
state$a.commands[command.id] = command;
|
|
466
706
|
} catch (error) {
|
|
467
707
|
const commandDisplayId = getCommandDisplay(command);
|
|
468
708
|
throw new VError$1(error, `Failed to register command${commandDisplayId}`);
|
|
@@ -470,7 +710,7 @@ const registerCommand = command => {
|
|
|
470
710
|
};
|
|
471
711
|
const executeCommand = async (id, ...args) => {
|
|
472
712
|
try {
|
|
473
|
-
const command = state$
|
|
713
|
+
const command = state$a.commands[id];
|
|
474
714
|
if (!command) {
|
|
475
715
|
throw new Error(`command ${id} not found`);
|
|
476
716
|
}
|
|
@@ -489,7 +729,7 @@ const {
|
|
|
489
729
|
registerCompletionProvider,
|
|
490
730
|
executeCompletionProvider,
|
|
491
731
|
executeresolveCompletionItemProvider
|
|
492
|
-
} = create$
|
|
732
|
+
} = create$9({
|
|
493
733
|
name: 'Completion',
|
|
494
734
|
resultShape: {
|
|
495
735
|
type: Array$1,
|
|
@@ -509,14 +749,24 @@ const {
|
|
|
509
749
|
}]
|
|
510
750
|
});
|
|
511
751
|
|
|
512
|
-
const state$
|
|
752
|
+
const state$9 = {
|
|
513
753
|
configuration: Object.create(null)
|
|
514
754
|
};
|
|
515
755
|
const getConfiguration = key => {
|
|
516
|
-
return state$
|
|
756
|
+
return state$9.configuration[key] ?? '';
|
|
757
|
+
};
|
|
758
|
+
const setConfigurations = preferences => {
|
|
759
|
+
state$9.configuration = preferences;
|
|
517
760
|
};
|
|
518
761
|
|
|
519
762
|
const Two = '2.0';
|
|
763
|
+
const create$4$1 = (method, params) => {
|
|
764
|
+
return {
|
|
765
|
+
jsonrpc: Two,
|
|
766
|
+
method,
|
|
767
|
+
params
|
|
768
|
+
};
|
|
769
|
+
};
|
|
520
770
|
class AssertionError extends Error {
|
|
521
771
|
constructor(message) {
|
|
522
772
|
super(message);
|
|
@@ -563,11 +813,11 @@ const get$2 = id => {
|
|
|
563
813
|
const remove = id => {
|
|
564
814
|
delete state$1$1.callbacks[id];
|
|
565
815
|
};
|
|
566
|
-
const state$
|
|
816
|
+
const state$8 = {
|
|
567
817
|
id: 0
|
|
568
818
|
};
|
|
569
819
|
const create$3$1 = () => {
|
|
570
|
-
return ++state$
|
|
820
|
+
return ++state$8.id;
|
|
571
821
|
};
|
|
572
822
|
const warn = (...args) => {
|
|
573
823
|
console.warn(...args);
|
|
@@ -798,7 +1048,7 @@ const getErrorResponse = (message, error, preparePrettyError, logError) => {
|
|
|
798
1048
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
799
1049
|
return create$1$1(message, errorProperty);
|
|
800
1050
|
};
|
|
801
|
-
const create$
|
|
1051
|
+
const create$8 = (message, result) => {
|
|
802
1052
|
return {
|
|
803
1053
|
jsonrpc: Two,
|
|
804
1054
|
id: message.id,
|
|
@@ -807,7 +1057,7 @@ const create$7 = (message, result) => {
|
|
|
807
1057
|
};
|
|
808
1058
|
const getSuccessResponse = (message, result) => {
|
|
809
1059
|
const resultProperty = result ?? null;
|
|
810
|
-
return create$
|
|
1060
|
+
return create$8(message, resultProperty);
|
|
811
1061
|
};
|
|
812
1062
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
813
1063
|
try {
|
|
@@ -873,6 +1123,10 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
873
1123
|
}
|
|
874
1124
|
throw new JsonRpcError('unexpected message');
|
|
875
1125
|
};
|
|
1126
|
+
const send$1 = (transport, method, ...params) => {
|
|
1127
|
+
const message = create$4$1(method, params);
|
|
1128
|
+
transport.send(message);
|
|
1129
|
+
};
|
|
876
1130
|
const invoke$1 = async (ipc, method, ...params) => {
|
|
877
1131
|
const {
|
|
878
1132
|
message,
|
|
@@ -905,10 +1159,13 @@ class CommandNotFoundError extends Error {
|
|
|
905
1159
|
}
|
|
906
1160
|
}
|
|
907
1161
|
|
|
908
|
-
const state$
|
|
1162
|
+
const state$7 = {};
|
|
1163
|
+
const register = commandMap => {
|
|
1164
|
+
Object.assign(state$7, commandMap);
|
|
1165
|
+
};
|
|
909
1166
|
const execute = (method, ...params) => {
|
|
910
1167
|
// @ts-ignore
|
|
911
|
-
const fn = state$
|
|
1168
|
+
const fn = state$7[method];
|
|
912
1169
|
// @ts-ignore
|
|
913
1170
|
if (!fn) {
|
|
914
1171
|
throw new CommandNotFoundError(method);
|
|
@@ -934,19 +1191,23 @@ const handleIpc = ipc => {
|
|
|
934
1191
|
ipc.addEventListener('message', handleMessage);
|
|
935
1192
|
};
|
|
936
1193
|
|
|
937
|
-
const state$
|
|
1194
|
+
const state$6 = {
|
|
938
1195
|
/**
|
|
939
1196
|
* @type {any}
|
|
940
1197
|
*/
|
|
941
1198
|
ipc: undefined
|
|
942
1199
|
};
|
|
943
1200
|
const get$1 = () => {
|
|
944
|
-
return state$
|
|
1201
|
+
return state$6.ipc;
|
|
945
1202
|
};
|
|
946
1203
|
const set$1 = ipc => {
|
|
947
|
-
state$
|
|
1204
|
+
state$6.ipc = ipc;
|
|
948
1205
|
};
|
|
949
1206
|
|
|
1207
|
+
const send = (method, ...params) => {
|
|
1208
|
+
const ipc = get$1();
|
|
1209
|
+
send$1(ipc, method, ...params);
|
|
1210
|
+
};
|
|
950
1211
|
const invoke = (method, ...params) => {
|
|
951
1212
|
const ipc = get$1();
|
|
952
1213
|
return invoke$1(ipc, method, ...params);
|
|
@@ -960,21 +1221,133 @@ const listen$2 = ipc => {
|
|
|
960
1221
|
set$1(ipc);
|
|
961
1222
|
};
|
|
962
1223
|
|
|
963
|
-
const state$
|
|
1224
|
+
const state$5 = {
|
|
964
1225
|
debugProviderMap: Object.create(null)
|
|
965
1226
|
};
|
|
1227
|
+
const getDebugProvider = id => {
|
|
1228
|
+
const provider = state$5.debugProviderMap[id];
|
|
1229
|
+
if (!provider) {
|
|
1230
|
+
// @ts-ignore
|
|
1231
|
+
throw new VError$1(`no debug provider "${id}" found`);
|
|
1232
|
+
}
|
|
1233
|
+
return provider;
|
|
1234
|
+
};
|
|
966
1235
|
const registerDebugProvider = debugProvider => {
|
|
967
1236
|
if (!debugProvider.id) {
|
|
968
1237
|
throw new Error('Failed to register debug system provider: missing id');
|
|
969
1238
|
}
|
|
970
|
-
state$
|
|
1239
|
+
state$5.debugProviderMap[debugProvider.id] = debugProvider;
|
|
1240
|
+
};
|
|
1241
|
+
const start = async (protocol, path) => {
|
|
1242
|
+
try {
|
|
1243
|
+
const handlePaused = params => {
|
|
1244
|
+
console.log('send paused', params);
|
|
1245
|
+
send('Debug.paused', params);
|
|
1246
|
+
};
|
|
1247
|
+
const handleResumed = () => {
|
|
1248
|
+
send('Debug.resumed');
|
|
1249
|
+
};
|
|
1250
|
+
const handleScriptParsed = parsedScript => {
|
|
1251
|
+
send('Debug.scriptParsed', parsedScript);
|
|
1252
|
+
};
|
|
1253
|
+
const provider = getDebugProvider(protocol);
|
|
1254
|
+
await provider.start({
|
|
1255
|
+
handlePaused,
|
|
1256
|
+
handleResumed,
|
|
1257
|
+
handleScriptParsed
|
|
1258
|
+
}, path);
|
|
1259
|
+
} catch (error) {
|
|
1260
|
+
throw new VError$1(error, 'Failed to execute debug provider');
|
|
1261
|
+
}
|
|
1262
|
+
};
|
|
1263
|
+
const listProcesses = async (protocol, path) => {
|
|
1264
|
+
try {
|
|
1265
|
+
const provider = getDebugProvider(protocol);
|
|
1266
|
+
const processes = await provider.listProcesses(path);
|
|
1267
|
+
array(processes);
|
|
1268
|
+
return processes;
|
|
1269
|
+
} catch (error) {
|
|
1270
|
+
throw new VError$1(error, 'Failed to execute debug provider');
|
|
1271
|
+
}
|
|
1272
|
+
};
|
|
1273
|
+
const resume = async protocol => {
|
|
1274
|
+
try {
|
|
1275
|
+
const provider = getDebugProvider(protocol);
|
|
1276
|
+
return await provider.resume();
|
|
1277
|
+
} catch (error) {
|
|
1278
|
+
throw new VError$1(error, 'Failed to execute debug provider');
|
|
1279
|
+
}
|
|
1280
|
+
};
|
|
1281
|
+
const pause = async protocol => {
|
|
1282
|
+
try {
|
|
1283
|
+
const provider = getDebugProvider(protocol);
|
|
1284
|
+
return await provider.pause();
|
|
1285
|
+
} catch (error) {
|
|
1286
|
+
throw new VError$1(error, 'Failed to execute debug provider');
|
|
1287
|
+
}
|
|
1288
|
+
};
|
|
1289
|
+
const stepInto = async protocol => {
|
|
1290
|
+
try {
|
|
1291
|
+
const provider = getDebugProvider(protocol);
|
|
1292
|
+
return await provider.stepInto();
|
|
1293
|
+
} catch (error) {
|
|
1294
|
+
throw new VError$1(error, 'Failed to execute debug provider');
|
|
1295
|
+
}
|
|
1296
|
+
};
|
|
1297
|
+
const stepOut = async protocol => {
|
|
1298
|
+
try {
|
|
1299
|
+
const provider = getDebugProvider(protocol);
|
|
1300
|
+
return await provider.stepOut();
|
|
1301
|
+
} catch (error) {
|
|
1302
|
+
throw new VError$1(error, 'Failed to execute debug provider');
|
|
1303
|
+
}
|
|
1304
|
+
};
|
|
1305
|
+
const stepOver = async protocol => {
|
|
1306
|
+
try {
|
|
1307
|
+
const provider = getDebugProvider(protocol);
|
|
1308
|
+
return await provider.stepOver();
|
|
1309
|
+
} catch (error) {
|
|
1310
|
+
throw new VError$1(error, 'Failed to execute debug provider');
|
|
1311
|
+
}
|
|
1312
|
+
};
|
|
1313
|
+
const setPauseOnException = async (protocol, value) => {
|
|
1314
|
+
try {
|
|
1315
|
+
const provider = getDebugProvider(protocol);
|
|
1316
|
+
return await provider.setPauseOnExceptions(value);
|
|
1317
|
+
} catch (error) {
|
|
1318
|
+
throw new VError$1(error, 'Failed to execute debug provider');
|
|
1319
|
+
}
|
|
1320
|
+
};
|
|
1321
|
+
const getProperties = async (protocol, objectId) => {
|
|
1322
|
+
try {
|
|
1323
|
+
const provider = getDebugProvider(protocol);
|
|
1324
|
+
return await provider.getProperties(objectId);
|
|
1325
|
+
} catch (error) {
|
|
1326
|
+
throw new VError$1(error, 'Failed to execute debug provider');
|
|
1327
|
+
}
|
|
1328
|
+
};
|
|
1329
|
+
const evaluate = async (protocol, expression, callFrameId) => {
|
|
1330
|
+
try {
|
|
1331
|
+
const provider = getDebugProvider(protocol);
|
|
1332
|
+
return await provider.evaluate(expression, callFrameId);
|
|
1333
|
+
} catch (error) {
|
|
1334
|
+
throw new VError$1(error, 'Failed to execute debug provider');
|
|
1335
|
+
}
|
|
1336
|
+
};
|
|
1337
|
+
const setPauseOnExceptions = async (protocol, value) => {
|
|
1338
|
+
try {
|
|
1339
|
+
const provider = getDebugProvider(protocol);
|
|
1340
|
+
return await provider.setPauseOnExceptions(value);
|
|
1341
|
+
} catch (error) {
|
|
1342
|
+
throw new VError$1(error, 'Failed to execute setPauseOnExceptions');
|
|
1343
|
+
}
|
|
971
1344
|
};
|
|
972
1345
|
|
|
973
1346
|
const {
|
|
974
1347
|
registerDefinitionProvider,
|
|
975
1348
|
executeDefinitionProvider,
|
|
976
1349
|
reset: reset$8
|
|
977
|
-
} = create$
|
|
1350
|
+
} = create$9({
|
|
978
1351
|
name: 'Definition',
|
|
979
1352
|
resultShape: {
|
|
980
1353
|
allowUndefined: true,
|
|
@@ -996,7 +1369,7 @@ const {
|
|
|
996
1369
|
const {
|
|
997
1370
|
registerDiagnosticProvider,
|
|
998
1371
|
executeDiagnosticProvider
|
|
999
|
-
} = create$
|
|
1372
|
+
} = create$9({
|
|
1000
1373
|
name: 'Diagnostic',
|
|
1001
1374
|
resultShape: {
|
|
1002
1375
|
type: Array$1,
|
|
@@ -1018,14 +1391,38 @@ const exec = async (command, args, options) => {
|
|
|
1018
1391
|
throw new DepecratedError(`vscode.exec is deprecated, use createNodeRpc instead`);
|
|
1019
1392
|
};
|
|
1020
1393
|
|
|
1021
|
-
const state$
|
|
1394
|
+
const state$4 = {
|
|
1022
1395
|
fileSystemProviderMap: Object.create(null)
|
|
1023
1396
|
};
|
|
1397
|
+
const getFileSystemProvider = protocol => {
|
|
1398
|
+
const provider = state$4.fileSystemProviderMap[protocol];
|
|
1399
|
+
if (!provider) {
|
|
1400
|
+
// @ts-ignore
|
|
1401
|
+
throw new VError$1(`no file system provider for protocol "${protocol}" found`);
|
|
1402
|
+
}
|
|
1403
|
+
return provider;
|
|
1404
|
+
};
|
|
1024
1405
|
const registerFileSystemProvider = fileSystemProvider => {
|
|
1025
1406
|
if (!fileSystemProvider.id) {
|
|
1026
1407
|
throw new Error('Failed to register file system provider: missing id');
|
|
1027
1408
|
}
|
|
1028
|
-
state$
|
|
1409
|
+
state$4.fileSystemProviderMap[fileSystemProvider.id] = fileSystemProvider;
|
|
1410
|
+
};
|
|
1411
|
+
const readDirWithFileTypes = async (protocol, path) => {
|
|
1412
|
+
try {
|
|
1413
|
+
const provider = getFileSystemProvider(protocol);
|
|
1414
|
+
return await provider.readDirWithFileTypes(path);
|
|
1415
|
+
} catch (error) {
|
|
1416
|
+
throw new VError$1(error, 'Failed to execute file system provider');
|
|
1417
|
+
}
|
|
1418
|
+
};
|
|
1419
|
+
const readFile = async (protocol, path) => {
|
|
1420
|
+
try {
|
|
1421
|
+
const provider = getFileSystemProvider(protocol);
|
|
1422
|
+
return await provider.readFile(path);
|
|
1423
|
+
} catch (error) {
|
|
1424
|
+
throw new VError$1(error, 'Failed to execute file system provider');
|
|
1425
|
+
}
|
|
1029
1426
|
};
|
|
1030
1427
|
const readFileExternal = async path => {
|
|
1031
1428
|
// TODO when file is local,
|
|
@@ -1037,16 +1434,101 @@ const readFileExternal = async path => {
|
|
|
1037
1434
|
const content = await invoke('FileSystem.readFile', path);
|
|
1038
1435
|
return content;
|
|
1039
1436
|
};
|
|
1437
|
+
const writeFile = async (protocol, uri, content) => {
|
|
1438
|
+
try {
|
|
1439
|
+
const provider = getFileSystemProvider(protocol);
|
|
1440
|
+
return await provider.writeFile(uri, content);
|
|
1441
|
+
} catch (error) {
|
|
1442
|
+
throw new VError$1(error, 'Failed to execute file system provider');
|
|
1443
|
+
}
|
|
1444
|
+
};
|
|
1445
|
+
const getPathSeparator = protocol => {
|
|
1446
|
+
try {
|
|
1447
|
+
const provider = getFileSystemProvider(protocol);
|
|
1448
|
+
return provider.pathSeparator;
|
|
1449
|
+
} catch (error) {
|
|
1450
|
+
throw new VError$1(error, 'Failed to execute file system provider');
|
|
1451
|
+
}
|
|
1452
|
+
};
|
|
1040
1453
|
|
|
1041
1454
|
const webViews = Object.create(null);
|
|
1042
1455
|
const webViewProviders = Object.create(null);
|
|
1456
|
+
const getProvider = providerId => {
|
|
1457
|
+
return webViewProviders[providerId];
|
|
1458
|
+
};
|
|
1043
1459
|
const setProvider = (providerId, provider) => {
|
|
1044
1460
|
webViewProviders[providerId] = provider;
|
|
1045
1461
|
};
|
|
1046
1462
|
const getWebView = id => {
|
|
1047
1463
|
return webViews[id];
|
|
1048
1464
|
};
|
|
1465
|
+
const setWebView = (id, webView) => {
|
|
1466
|
+
webViews[id] = webView;
|
|
1467
|
+
};
|
|
1468
|
+
|
|
1469
|
+
// TODO pass uuid to allow having multiple webviews open at the same time
|
|
1470
|
+
const createWebView = async (providerId, port, uri, uid, origin) => {
|
|
1471
|
+
const provider = getProvider(providerId);
|
|
1472
|
+
if (!provider) {
|
|
1473
|
+
throw new Error(`webview provider ${providerId} not found`);
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
// TODO cancel promise when webview is disposed before sending message
|
|
1477
|
+
// TODO handle case when webview doesn't send ready message
|
|
1478
|
+
// TODO handle error
|
|
1479
|
+
await new Promise(resolve => {
|
|
1480
|
+
port.onmessage = resolve;
|
|
1481
|
+
});
|
|
1049
1482
|
|
|
1483
|
+
// TODO use ipc module
|
|
1484
|
+
const handlePortMessage = async event => {
|
|
1485
|
+
const {
|
|
1486
|
+
data,
|
|
1487
|
+
target
|
|
1488
|
+
} = event;
|
|
1489
|
+
const {
|
|
1490
|
+
method,
|
|
1491
|
+
params,
|
|
1492
|
+
id
|
|
1493
|
+
} = data;
|
|
1494
|
+
if (provider && provider.commands && provider.commands[method]) {
|
|
1495
|
+
const fn = provider.commands[method];
|
|
1496
|
+
const result = await fn(...params);
|
|
1497
|
+
if (id) {
|
|
1498
|
+
target.postMessage({
|
|
1499
|
+
jsonrpc: '2.0',
|
|
1500
|
+
id,
|
|
1501
|
+
result
|
|
1502
|
+
});
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
};
|
|
1506
|
+
port.onmessage = handlePortMessage;
|
|
1507
|
+
const rpc = {
|
|
1508
|
+
uri,
|
|
1509
|
+
provider,
|
|
1510
|
+
uid,
|
|
1511
|
+
origin,
|
|
1512
|
+
invoke(method, ...params) {
|
|
1513
|
+
// TODO return promise with result
|
|
1514
|
+
port.postMessage({
|
|
1515
|
+
jsonrpc: '2.0',
|
|
1516
|
+
method,
|
|
1517
|
+
params
|
|
1518
|
+
});
|
|
1519
|
+
}
|
|
1520
|
+
};
|
|
1521
|
+
// TODO allow creating multiple webviews per provider
|
|
1522
|
+
setWebView(providerId, rpc);
|
|
1523
|
+
};
|
|
1524
|
+
const load = async providerId => {
|
|
1525
|
+
const rpc = getWebView(providerId);
|
|
1526
|
+
await rpc.provider.create(rpc, rpc.uri);
|
|
1527
|
+
};
|
|
1528
|
+
const disposeWebView = id => {
|
|
1529
|
+
// TODO race condition
|
|
1530
|
+
// const webView=webViews[id]
|
|
1531
|
+
};
|
|
1050
1532
|
const registerWebViewProvider = provider => {
|
|
1051
1533
|
setProvider(provider.id, provider);
|
|
1052
1534
|
};
|
|
@@ -1055,7 +1537,7 @@ const {
|
|
|
1055
1537
|
registerFormattingProvider,
|
|
1056
1538
|
executeFormattingProvider,
|
|
1057
1539
|
reset: reset$7
|
|
1058
|
-
} = create$
|
|
1540
|
+
} = create$9({
|
|
1059
1541
|
name: 'Formatting',
|
|
1060
1542
|
executeKey: 'format',
|
|
1061
1543
|
resultShape: {
|
|
@@ -1117,7 +1599,7 @@ const {
|
|
|
1117
1599
|
registerHoverProvider,
|
|
1118
1600
|
executeHoverProvider,
|
|
1119
1601
|
reset: reset$6
|
|
1120
|
-
} = create$
|
|
1602
|
+
} = create$9({
|
|
1121
1603
|
name: 'Hover',
|
|
1122
1604
|
resultShape: {
|
|
1123
1605
|
allowUndefined: true,
|
|
@@ -1130,7 +1612,7 @@ const {
|
|
|
1130
1612
|
registerImplementationProvider,
|
|
1131
1613
|
executeImplementationProvider,
|
|
1132
1614
|
reset: reset$5
|
|
1133
|
-
} = create$
|
|
1615
|
+
} = create$9({
|
|
1134
1616
|
name: 'Implementation',
|
|
1135
1617
|
resultShape: {
|
|
1136
1618
|
type: Array$1,
|
|
@@ -1157,7 +1639,7 @@ const getModule$3 = method => {
|
|
|
1157
1639
|
}
|
|
1158
1640
|
};
|
|
1159
1641
|
|
|
1160
|
-
const create$
|
|
1642
|
+
const create$7 = async ({
|
|
1161
1643
|
method,
|
|
1162
1644
|
...options
|
|
1163
1645
|
}) => {
|
|
@@ -1184,7 +1666,7 @@ const getModule$2 = method => {
|
|
|
1184
1666
|
}
|
|
1185
1667
|
};
|
|
1186
1668
|
|
|
1187
|
-
const create$
|
|
1669
|
+
const create$6 = async ({
|
|
1188
1670
|
method,
|
|
1189
1671
|
...options
|
|
1190
1672
|
}) => {
|
|
@@ -1205,12 +1687,12 @@ const createNodeRpc = async ({
|
|
|
1205
1687
|
try {
|
|
1206
1688
|
string(path);
|
|
1207
1689
|
fn(execute);
|
|
1208
|
-
const ipc = await create$
|
|
1690
|
+
const ipc = await create$7({
|
|
1209
1691
|
method: ElectronMessagePort,
|
|
1210
1692
|
type: 'extension-host-helper-process',
|
|
1211
1693
|
name
|
|
1212
1694
|
});
|
|
1213
|
-
const rpc = await create$
|
|
1695
|
+
const rpc = await create$6({
|
|
1214
1696
|
ipc,
|
|
1215
1697
|
method: JsonRpc,
|
|
1216
1698
|
execute
|
|
@@ -1244,7 +1726,7 @@ const {
|
|
|
1244
1726
|
executeReferenceProvider,
|
|
1245
1727
|
executefileReferenceProvider,
|
|
1246
1728
|
reset: reset$4
|
|
1247
|
-
} = create$
|
|
1729
|
+
} = create$9({
|
|
1248
1730
|
name: 'Reference',
|
|
1249
1731
|
resultShape: {
|
|
1250
1732
|
type: Array$1,
|
|
@@ -1271,7 +1753,7 @@ const {
|
|
|
1271
1753
|
executeRenameProvider,
|
|
1272
1754
|
executeprepareRenameProvider,
|
|
1273
1755
|
reset: reset$3
|
|
1274
|
-
} = create$
|
|
1756
|
+
} = create$9({
|
|
1275
1757
|
name: 'Rename',
|
|
1276
1758
|
resultShape: {
|
|
1277
1759
|
type: Object$1,
|
|
@@ -1290,6 +1772,9 @@ const {
|
|
|
1290
1772
|
});
|
|
1291
1773
|
|
|
1292
1774
|
const rpcs = Object.create(null);
|
|
1775
|
+
const add$1 = (id, rpc) => {
|
|
1776
|
+
rpcs[id] = rpc;
|
|
1777
|
+
};
|
|
1293
1778
|
const get = id => {
|
|
1294
1779
|
return rpcs[id];
|
|
1295
1780
|
};
|
|
@@ -1308,12 +1793,12 @@ const createRpcWithId = async ({
|
|
|
1308
1793
|
if (!info) {
|
|
1309
1794
|
throw new Error(`rpc with id ${id} not found`);
|
|
1310
1795
|
}
|
|
1311
|
-
const ipc = await create$
|
|
1796
|
+
const ipc = await create$7({
|
|
1312
1797
|
method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug$1,
|
|
1313
1798
|
url: extensionHostSubWorkerUrl,
|
|
1314
1799
|
name: info.name
|
|
1315
1800
|
});
|
|
1316
|
-
const rpc = await create$
|
|
1801
|
+
const rpc = await create$6({
|
|
1317
1802
|
ipc,
|
|
1318
1803
|
method: JsonRpc,
|
|
1319
1804
|
execute
|
|
@@ -1354,12 +1839,12 @@ const createRpc = async ({
|
|
|
1354
1839
|
if (contentSecurityPolicy) {
|
|
1355
1840
|
await set(url, contentSecurityPolicy);
|
|
1356
1841
|
}
|
|
1357
|
-
const ipc = await create$
|
|
1842
|
+
const ipc = await create$7({
|
|
1358
1843
|
method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug$1,
|
|
1359
1844
|
url: extensionHostSubWorkerUrl,
|
|
1360
1845
|
name
|
|
1361
1846
|
});
|
|
1362
|
-
const rpc = await create$
|
|
1847
|
+
const rpc = await create$6({
|
|
1363
1848
|
ipc,
|
|
1364
1849
|
method: JsonRpc,
|
|
1365
1850
|
execute
|
|
@@ -1375,7 +1860,7 @@ const {
|
|
|
1375
1860
|
registerSelectionProvider,
|
|
1376
1861
|
executeSelectionProvider,
|
|
1377
1862
|
reset: reset$2
|
|
1378
|
-
} = create$
|
|
1863
|
+
} = create$9({
|
|
1379
1864
|
name: 'Selection',
|
|
1380
1865
|
resultShape: {
|
|
1381
1866
|
allowUndefined: true,
|
|
@@ -1386,18 +1871,104 @@ const {
|
|
|
1386
1871
|
}
|
|
1387
1872
|
});
|
|
1388
1873
|
|
|
1389
|
-
const state$
|
|
1874
|
+
const state$3 = {
|
|
1390
1875
|
providers: Object.create(null)
|
|
1391
1876
|
};
|
|
1392
1877
|
const registerSourceControlProvider = provider => {
|
|
1393
|
-
state$
|
|
1878
|
+
state$3.providers[provider.id] = provider;
|
|
1879
|
+
};
|
|
1880
|
+
const getFilesFromProvider = provider => {
|
|
1881
|
+
return provider.getChangedFiles();
|
|
1882
|
+
};
|
|
1883
|
+
const getChangedFiles = async providerId => {
|
|
1884
|
+
const provider = state$3.providers[providerId];
|
|
1885
|
+
if (!provider) {
|
|
1886
|
+
throw new Error('no source control provider found');
|
|
1887
|
+
}
|
|
1888
|
+
const changedFiles = await getFilesFromProvider(provider);
|
|
1889
|
+
const flattenedChangedFiles = changedFiles;
|
|
1890
|
+
return flattenedChangedFiles;
|
|
1891
|
+
};
|
|
1892
|
+
const getFileBefore = async (providerId, uri) => {
|
|
1893
|
+
string(providerId);
|
|
1894
|
+
string(uri);
|
|
1895
|
+
const provider = state$3.providers[providerId];
|
|
1896
|
+
if (!provider) {
|
|
1897
|
+
throw new Error('no source control provider found');
|
|
1898
|
+
}
|
|
1899
|
+
return provider.getFileBefore(uri);
|
|
1900
|
+
};
|
|
1901
|
+
const getGroupsFromProvider = async (provider, cwd) => {
|
|
1902
|
+
if (provider.getGroups) {
|
|
1903
|
+
return provider.getGroups(cwd);
|
|
1904
|
+
}
|
|
1905
|
+
if (provider.getChangedFiles) {
|
|
1906
|
+
const files = await provider.getChangedFiles();
|
|
1907
|
+
const groups = [{
|
|
1908
|
+
id: 'changes',
|
|
1909
|
+
label: 'Changes',
|
|
1910
|
+
items: files
|
|
1911
|
+
}];
|
|
1912
|
+
return groups;
|
|
1913
|
+
}
|
|
1914
|
+
throw new Error('source control provider is missing required function getGroups');
|
|
1915
|
+
};
|
|
1916
|
+
const getGroups = async (providerId, cwd) => {
|
|
1917
|
+
const provider = state$3.providers[providerId];
|
|
1918
|
+
if (!provider) {
|
|
1919
|
+
throw new Error('no source control provider found');
|
|
1920
|
+
}
|
|
1921
|
+
const groups = await getGroupsFromProvider(provider, cwd);
|
|
1922
|
+
return groups;
|
|
1923
|
+
};
|
|
1924
|
+
const acceptInput = async (providerId, value) => {
|
|
1925
|
+
const provider = state$3.providers[providerId];
|
|
1926
|
+
if (!provider) {
|
|
1927
|
+
throw new Error('no source control provider found');
|
|
1928
|
+
}
|
|
1929
|
+
await provider.acceptInput(value);
|
|
1930
|
+
};
|
|
1931
|
+
const add = async path => {
|
|
1932
|
+
const provider = Object.values(state$3.providers)[0];
|
|
1933
|
+
if (!provider) {
|
|
1934
|
+
return;
|
|
1935
|
+
}
|
|
1936
|
+
// @ts-ignore
|
|
1937
|
+
await provider.add(path);
|
|
1938
|
+
};
|
|
1939
|
+
const discard = async path => {
|
|
1940
|
+
const provider = Object.values(state$3.providers)[0];
|
|
1941
|
+
if (!provider) {
|
|
1942
|
+
return;
|
|
1943
|
+
}
|
|
1944
|
+
// @ts-ignore
|
|
1945
|
+
await provider.discard(path);
|
|
1946
|
+
};
|
|
1947
|
+
const getEnabledProviderIds = async (scheme, root) => {
|
|
1948
|
+
string(scheme);
|
|
1949
|
+
string(root);
|
|
1950
|
+
const providers = Object.values(state$3.providers);
|
|
1951
|
+
const enabledIds = [];
|
|
1952
|
+
for (const provider of providers) {
|
|
1953
|
+
// @ts-ignore
|
|
1954
|
+
if (typeof provider.isActive !== 'function') {
|
|
1955
|
+
continue;
|
|
1956
|
+
}
|
|
1957
|
+
// @ts-ignore
|
|
1958
|
+
const isActive = await provider.isActive(scheme, root);
|
|
1959
|
+
if (isActive) {
|
|
1960
|
+
// @ts-ignore
|
|
1961
|
+
enabledIds.push(provider.id);
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
return enabledIds;
|
|
1394
1965
|
};
|
|
1395
1966
|
|
|
1396
1967
|
const {
|
|
1397
1968
|
registerTabCompletionProvider,
|
|
1398
1969
|
executeTabCompletionProvider,
|
|
1399
1970
|
reset: reset$1
|
|
1400
|
-
} = create$
|
|
1971
|
+
} = create$9({
|
|
1401
1972
|
name: 'TabCompletion',
|
|
1402
1973
|
resultShape: {
|
|
1403
1974
|
type: Object$1,
|
|
@@ -1405,7 +1976,7 @@ const {
|
|
|
1405
1976
|
}
|
|
1406
1977
|
});
|
|
1407
1978
|
|
|
1408
|
-
const state$
|
|
1979
|
+
const state$2 = {
|
|
1409
1980
|
textSearchProviders: Object.create(null)
|
|
1410
1981
|
};
|
|
1411
1982
|
const registerTextSearchProvider = textSearchProvider => {
|
|
@@ -1416,14 +1987,14 @@ const registerTextSearchProvider = textSearchProvider => {
|
|
|
1416
1987
|
if (!textSearchProvider.scheme) {
|
|
1417
1988
|
throw new Error('textSearchProvider is missing scheme');
|
|
1418
1989
|
}
|
|
1419
|
-
state$
|
|
1990
|
+
state$2.textSearchProviders[textSearchProvider.scheme] = textSearchProvider;
|
|
1420
1991
|
} catch (error) {
|
|
1421
1992
|
throw new VError$1(error, 'Failed to register text search provider');
|
|
1422
1993
|
}
|
|
1423
1994
|
};
|
|
1424
1995
|
const executeTextSearchProvider = async (scheme, query) => {
|
|
1425
1996
|
try {
|
|
1426
|
-
const textSearchProvider = state$
|
|
1997
|
+
const textSearchProvider = state$2.textSearchProviders[scheme];
|
|
1427
1998
|
if (!textSearchProvider) {
|
|
1428
1999
|
throw new Error(`no text search provider for ${scheme} found`);
|
|
1429
2000
|
}
|
|
@@ -1438,7 +2009,7 @@ const {
|
|
|
1438
2009
|
registerTypeDefinitionProvider,
|
|
1439
2010
|
executeTypeDefinitionProvider,
|
|
1440
2011
|
reset
|
|
1441
|
-
} = create$
|
|
2012
|
+
} = create$9({
|
|
1442
2013
|
name: 'TypeDefinition',
|
|
1443
2014
|
resultShape: {
|
|
1444
2015
|
allowUndefined: true,
|
|
@@ -1465,7 +2036,7 @@ const createWorker = async ({
|
|
|
1465
2036
|
string(method);
|
|
1466
2037
|
string(url);
|
|
1467
2038
|
string(name);
|
|
1468
|
-
const ipc = create$
|
|
2039
|
+
const ipc = create$7({
|
|
1469
2040
|
method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug$1,
|
|
1470
2041
|
url,
|
|
1471
2042
|
name
|
|
@@ -1473,11 +2044,14 @@ const createWorker = async ({
|
|
|
1473
2044
|
return ipc;
|
|
1474
2045
|
};
|
|
1475
2046
|
|
|
1476
|
-
const state = {
|
|
2047
|
+
const state$1 = {
|
|
1477
2048
|
workspacePath: ''
|
|
1478
2049
|
};
|
|
2050
|
+
const setWorkspacePath = path => {
|
|
2051
|
+
state$1.workspacePath = path;
|
|
2052
|
+
};
|
|
1479
2053
|
const getWorkspaceFolder = path => {
|
|
1480
|
-
return state.workspacePath;
|
|
2054
|
+
return state$1.workspacePath;
|
|
1481
2055
|
};
|
|
1482
2056
|
|
|
1483
2057
|
const RE_PROTOCOL = /^([a-z\-]+):\/\//;
|
|
@@ -1607,12 +2181,12 @@ class FormattingError extends Error {
|
|
|
1607
2181
|
}
|
|
1608
2182
|
}
|
|
1609
2183
|
|
|
1610
|
-
const File = 1;
|
|
2184
|
+
const File$1 = 1;
|
|
1611
2185
|
const Match = 2;
|
|
1612
2186
|
|
|
1613
2187
|
const TextSearchResultType = {
|
|
1614
2188
|
__proto__: null,
|
|
1615
|
-
File,
|
|
2189
|
+
File: File$1,
|
|
1616
2190
|
Match
|
|
1617
2191
|
};
|
|
1618
2192
|
|
|
@@ -1710,6 +2284,177 @@ const api = {
|
|
|
1710
2284
|
getWorkspaceFolder: getWorkspaceFolder
|
|
1711
2285
|
};
|
|
1712
2286
|
|
|
2287
|
+
const BraceCompletionExecuteBraceCompletionProvider = 'ExtensionHostBraceCompletion.executeBraceCompletionProvider';
|
|
2288
|
+
const ClosingTagExecuteClosingTagProvider = 'ExtensionHostClosingTag.executeClosingTagProvider';
|
|
2289
|
+
const CommandExecute = 'ExtensionHostCommand.executeCommand';
|
|
2290
|
+
const CompletionExecute = 'ExtensionHostCompletion.execute';
|
|
2291
|
+
const CompletionResolveExecute = 'ExtensionHostCompletion.executeResolve';
|
|
2292
|
+
const DefinitionExecuteDefinitionProvider = 'ExtensionHostDefinition.executeDefinitionProvider';
|
|
2293
|
+
const DiagnosticExecuteDiagnosticProvider = 'ExtensionHost.executeDiagnosticProvider';
|
|
2294
|
+
const ExtensionActivate = 'ExtensionHostExtension.activate';
|
|
2295
|
+
const FileSystemGetPathSeparator = 'ExtensionHostFileSystem.getPathSeparator';
|
|
2296
|
+
const FileSystemReadDirWithFileTypes = 'ExtensionHostFileSystem.readDirWithFileTypes';
|
|
2297
|
+
const FileSystemReadFile = 'ExtensionHostFileSystem.readFile';
|
|
2298
|
+
const FileSystemWriteFile = 'ExtensionHostFileSystem.writeFile';
|
|
2299
|
+
const FormattingExecuteFormmattingProvider = 'ExtensionHostFormatting.executeFormattingProvider';
|
|
2300
|
+
const HoverExecute = 'ExtensionHostHover.execute';
|
|
2301
|
+
const ImplementationExecuteImplementationProvider = 'ExtensionHostImplementation.executeImplementationProvider';
|
|
2302
|
+
const MockExec = 'ExtensionHostMockExec.mockExec';
|
|
2303
|
+
const MockRpc = 'ExtensionHostMockRpc.mockRpc';
|
|
2304
|
+
const OrganizeImportsExecute = 'ExtensionHostOrganizeImports.execute';
|
|
2305
|
+
const ReferenceExecuteFileReferenceProvider = 'ExtensionHostReference.executeFileReferenceProvider';
|
|
2306
|
+
const ReferenceExecuteReferenceProvider = 'ExtensionHostReference.executeReferenceProvider';
|
|
2307
|
+
const SourceControlAcceptInput = 'ExtensionHostSourceControl.acceptInput';
|
|
2308
|
+
const SourceControlAdd = 'ExtensionHostSourceControl.add';
|
|
2309
|
+
const SourceControlDiscard = 'ExtensionHostSourceControl.discard';
|
|
2310
|
+
const SourceControlGetChangedFiles = 'ExtensionHost.sourceControlGetChangedFiles';
|
|
2311
|
+
const SourceControlGetEnabledProviderIds = 'ExtensionHostSourceControl.getEnabledProviderIds';
|
|
2312
|
+
const SourceControlGetFileBefore = 'ExtensionHostSourceControl.GetFileBefore';
|
|
2313
|
+
const SourceControlGetGroups = 'ExtensionHostSourceControl.getGroups';
|
|
2314
|
+
const StatusBarGetStatusBarItems = 'ExtensionHost.getStatusBarItems';
|
|
2315
|
+
const StatusBarRegisterChangeListener = 'ExtensionHostStatusBar.registerChangeListener';
|
|
2316
|
+
const TabCompletionExecuteTabCompletionProvider = 'ExtensionHost.executeTabCompletionProvider';
|
|
2317
|
+
const TextDocumentSetLanguageId = 'ExtensionHostTextDocument.setLanguageId';
|
|
2318
|
+
const TextDocumentSyncFull = 'ExtensionHostTextDocument.syncFull';
|
|
2319
|
+
const TextDocumentSyncIncremental = 'ExtensionHostTextDocument.syncIncremental';
|
|
2320
|
+
const TextSearchExecuteTextSearchProvider = 'ExtensionHostTextSearch.executeTextSearchProvider';
|
|
2321
|
+
const TypeDefinitionExecuteTypeDefinitionProvider = 'ExtensionHostTypeDefinition.executeTypeDefinitionProvider';
|
|
2322
|
+
const WorkspaceSetPath = 'Workspace.setWorkspacePath';
|
|
2323
|
+
const SelectionExecuteSelectionProvider = 'ExtensionHostSelection.executeSelectionProvider';
|
|
2324
|
+
const ConfigurationSetConfiguration = 'ExtensionHostConfiguration.setConfiguration';
|
|
2325
|
+
|
|
2326
|
+
const create$5 = () => {
|
|
2327
|
+
return {
|
|
2328
|
+
finished: false
|
|
2329
|
+
};
|
|
2330
|
+
};
|
|
2331
|
+
const cancel = token => {
|
|
2332
|
+
token.finished = true;
|
|
2333
|
+
};
|
|
2334
|
+
const isCanceled = token => {
|
|
2335
|
+
return token.finished;
|
|
2336
|
+
};
|
|
2337
|
+
|
|
2338
|
+
const baseName = path => {
|
|
2339
|
+
const slashIndex = path.lastIndexOf('/');
|
|
2340
|
+
return path.slice(slashIndex + 1);
|
|
2341
|
+
};
|
|
2342
|
+
const getExtensionId = extension => {
|
|
2343
|
+
if (extension && extension.id) {
|
|
2344
|
+
return extension.id;
|
|
2345
|
+
}
|
|
2346
|
+
if (extension && extension.path) {
|
|
2347
|
+
return baseName(extension.path);
|
|
2348
|
+
}
|
|
2349
|
+
return '<unknown>';
|
|
2350
|
+
};
|
|
2351
|
+
|
|
2352
|
+
const getUrlPrefix = extensionPath => {
|
|
2353
|
+
if (extensionPath.startsWith('http://') || extensionPath.startsWith('https://')) {
|
|
2354
|
+
return extensionPath;
|
|
2355
|
+
}
|
|
2356
|
+
return `/remote/${extensionPath}`;
|
|
2357
|
+
};
|
|
2358
|
+
const handleRpcInfos = extension => {
|
|
2359
|
+
try {
|
|
2360
|
+
if (!extension) {
|
|
2361
|
+
return;
|
|
2362
|
+
}
|
|
2363
|
+
const rpcs = extension.rpc;
|
|
2364
|
+
const urlPrefix = getUrlPrefix(extension.path);
|
|
2365
|
+
if (!rpcs) {
|
|
2366
|
+
return;
|
|
2367
|
+
}
|
|
2368
|
+
if (!Array.isArray(rpcs)) {
|
|
2369
|
+
return;
|
|
2370
|
+
}
|
|
2371
|
+
for (const rpc of rpcs) {
|
|
2372
|
+
rpc.url = `${urlPrefix}/${rpc.url}`;
|
|
2373
|
+
add$1(rpc.id, rpc);
|
|
2374
|
+
}
|
|
2375
|
+
} catch (error) {
|
|
2376
|
+
console.warn(`Failed to handle extension rpcs: ${error}`);
|
|
2377
|
+
}
|
|
2378
|
+
};
|
|
2379
|
+
|
|
2380
|
+
class ContentSecurityPolicyError extends Error {
|
|
2381
|
+
constructor(violatedDirective, sourceFile, lineNumber, columnNumber) {
|
|
2382
|
+
super(`Content Security Policy Violation: ${violatedDirective}`);
|
|
2383
|
+
this.name = 'ContentSecurityPolicyError';
|
|
2384
|
+
if (sourceFile) {
|
|
2385
|
+
this.stack = `Content Security Policy Violation
|
|
2386
|
+
at ${sourceFile}:${lineNumber}:${columnNumber}`;
|
|
2387
|
+
} else {
|
|
2388
|
+
this.stack = `Content Security Policy Violation
|
|
2389
|
+
at <unknown>`;
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
|
|
2394
|
+
const state = {
|
|
2395
|
+
/**
|
|
2396
|
+
* @type {any[]}
|
|
2397
|
+
*/
|
|
2398
|
+
errors: []
|
|
2399
|
+
};
|
|
2400
|
+
const addError = error => {
|
|
2401
|
+
// @ts-ignore
|
|
2402
|
+
state.errors.push(error);
|
|
2403
|
+
};
|
|
2404
|
+
const hasRecentErrors = () => {
|
|
2405
|
+
return state.errors.length > 0;
|
|
2406
|
+
};
|
|
2407
|
+
const getRecentError = () => {
|
|
2408
|
+
return state.errors.at(-1);
|
|
2409
|
+
};
|
|
2410
|
+
|
|
2411
|
+
const isImportErrorChrome = error => {
|
|
2412
|
+
return error && error instanceof Error && error.message.startsWith('Failed to fetch dynamically imported module');
|
|
2413
|
+
};
|
|
2414
|
+
|
|
2415
|
+
const isImportErrorFirefox = error => {
|
|
2416
|
+
return error && error instanceof TypeError && error.message === 'error loading dynamically imported module';
|
|
2417
|
+
};
|
|
2418
|
+
|
|
2419
|
+
const isSyntaxError = error => {
|
|
2420
|
+
return error instanceof SyntaxError;
|
|
2421
|
+
};
|
|
2422
|
+
|
|
2423
|
+
const isImportError = error => {
|
|
2424
|
+
return isImportErrorChrome(error) || isImportErrorFirefox(error) || isSyntaxError(error);
|
|
2425
|
+
};
|
|
2426
|
+
|
|
2427
|
+
const sleep = duration => {
|
|
2428
|
+
const promiseCallback = (resolve, reject) => {
|
|
2429
|
+
setTimeout(resolve, duration);
|
|
2430
|
+
};
|
|
2431
|
+
return new Promise(promiseCallback);
|
|
2432
|
+
};
|
|
2433
|
+
|
|
2434
|
+
const NotFound = 404;
|
|
2435
|
+
|
|
2436
|
+
const RE_LINE_COLUMN = /(.*)(?:\(\d+\:\d+\))/;
|
|
2437
|
+
const getBabelErrorMessage = message => {
|
|
2438
|
+
const match = message.match(RE_LINE_COLUMN);
|
|
2439
|
+
if (match) {
|
|
2440
|
+
return match[1].trim();
|
|
2441
|
+
}
|
|
2442
|
+
return message;
|
|
2443
|
+
};
|
|
2444
|
+
class BabelParseError extends SyntaxError {
|
|
2445
|
+
constructor(url, error) {
|
|
2446
|
+
const message = getBabelErrorMessage(error.message);
|
|
2447
|
+
super(message);
|
|
2448
|
+
this.name = 'BabelParseError';
|
|
2449
|
+
// @ts-ignore
|
|
2450
|
+
const line = error.loc.line;
|
|
2451
|
+
// @ts-ignore
|
|
2452
|
+
const column = error.loc.column + 1;
|
|
2453
|
+
this.stack = `${message}
|
|
2454
|
+
at ${url}:${line}:${column}`;
|
|
2455
|
+
}
|
|
2456
|
+
}
|
|
2457
|
+
|
|
1713
2458
|
const getAssetDir = () => {
|
|
1714
2459
|
// @ts-ignore
|
|
1715
2460
|
if (typeof ASSET_DIR !== 'undefined') {
|
|
@@ -1721,7 +2466,385 @@ const getAssetDir = () => {
|
|
|
1721
2466
|
}
|
|
1722
2467
|
return '';
|
|
1723
2468
|
};
|
|
1724
|
-
getAssetDir();
|
|
2469
|
+
const assetDir = getAssetDir();
|
|
2470
|
+
|
|
2471
|
+
const loadBabelParser = () => {
|
|
2472
|
+
const url = `${assetDir}/js/babel-parser.js`;
|
|
2473
|
+
return import(url);
|
|
2474
|
+
};
|
|
2475
|
+
|
|
2476
|
+
const parse = async (code, options) => {
|
|
2477
|
+
const BabelParse = await loadBabelParser();
|
|
2478
|
+
return BabelParse.parse(code, options);
|
|
2479
|
+
};
|
|
2480
|
+
|
|
2481
|
+
const Module = 'module';
|
|
2482
|
+
|
|
2483
|
+
const getLineAndColumn = (text, start, end) => {
|
|
2484
|
+
let index = -1;
|
|
2485
|
+
let line = 0;
|
|
2486
|
+
const column = 0;
|
|
2487
|
+
while ((index = text.indexOf('\n', index + 1)) !== -1) {
|
|
2488
|
+
line++;
|
|
2489
|
+
if (index >= start) {
|
|
2490
|
+
break;
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
return {
|
|
2494
|
+
line,
|
|
2495
|
+
column
|
|
2496
|
+
};
|
|
2497
|
+
};
|
|
2498
|
+
|
|
2499
|
+
class DependencyNotFoundError extends Error {
|
|
2500
|
+
constructor(code, start, end, dependencyRelativePath, dependencyUrl, sourceUrl) {
|
|
2501
|
+
super(`Module not found "${dependencyRelativePath}"`);
|
|
2502
|
+
const {
|
|
2503
|
+
line,
|
|
2504
|
+
column
|
|
2505
|
+
} = getLineAndColumn(code, start);
|
|
2506
|
+
this.stack = `${this.message}
|
|
2507
|
+
at Module (${sourceUrl}:${line}:${column})`;
|
|
2508
|
+
}
|
|
2509
|
+
}
|
|
2510
|
+
|
|
2511
|
+
const ArrowFunctionExpression = 'ArrowFunctionExpression';
|
|
2512
|
+
const AwaitExpression = 'AwaitExpression';
|
|
2513
|
+
const BlockStatement = 'BlockStatement';
|
|
2514
|
+
const CallExpression = 'CallExpression';
|
|
2515
|
+
const ExportAllDeclaration = 'ExportAllDeclaration';
|
|
2516
|
+
const ExportNamedDeclaration = 'ExportNamedDeclaration';
|
|
2517
|
+
const ExpressionStatement = 'ExpressionStatement';
|
|
2518
|
+
const File = 'File';
|
|
2519
|
+
const Import = 'Import';
|
|
2520
|
+
const ImportDeclaration = 'ImportDeclaration';
|
|
2521
|
+
const Program = 'Program';
|
|
2522
|
+
const StringLiteral = 'StringLiteral';
|
|
2523
|
+
const VariableDeclaration = 'VariableDeclaration';
|
|
2524
|
+
const VariableDeclarator = 'VariableDeclarator';
|
|
2525
|
+
|
|
2526
|
+
const walk = (node, visitor) => {
|
|
2527
|
+
if (!node) {
|
|
2528
|
+
return;
|
|
2529
|
+
}
|
|
2530
|
+
if (Array.isArray(node)) {
|
|
2531
|
+
for (const item of node) {
|
|
2532
|
+
walk(item, visitor);
|
|
2533
|
+
}
|
|
2534
|
+
return;
|
|
2535
|
+
}
|
|
2536
|
+
visitor(node);
|
|
2537
|
+
switch (node.type) {
|
|
2538
|
+
case File:
|
|
2539
|
+
walk(node.program, visitor);
|
|
2540
|
+
break;
|
|
2541
|
+
case Program:
|
|
2542
|
+
walk(node.body, visitor);
|
|
2543
|
+
break;
|
|
2544
|
+
case ExportNamedDeclaration:
|
|
2545
|
+
walk(node.declaration, visitor);
|
|
2546
|
+
break;
|
|
2547
|
+
case VariableDeclaration:
|
|
2548
|
+
walk(node.declarations, visitor);
|
|
2549
|
+
break;
|
|
2550
|
+
case VariableDeclarator:
|
|
2551
|
+
walk(node.init, visitor);
|
|
2552
|
+
break;
|
|
2553
|
+
case ArrowFunctionExpression:
|
|
2554
|
+
walk(node.body, visitor);
|
|
2555
|
+
break;
|
|
2556
|
+
case BlockStatement:
|
|
2557
|
+
walk(node.body, visitor);
|
|
2558
|
+
break;
|
|
2559
|
+
case ExpressionStatement:
|
|
2560
|
+
walk(node.expression, visitor);
|
|
2561
|
+
break;
|
|
2562
|
+
case AwaitExpression:
|
|
2563
|
+
walk(node.argument, visitor);
|
|
2564
|
+
break;
|
|
2565
|
+
case CallExpression:
|
|
2566
|
+
walk(node.callee, visitor);
|
|
2567
|
+
break;
|
|
2568
|
+
}
|
|
2569
|
+
};
|
|
2570
|
+
const getBabelAstDependencies = (code, ast) => {
|
|
2571
|
+
const {
|
|
2572
|
+
program
|
|
2573
|
+
} = ast;
|
|
2574
|
+
const {
|
|
2575
|
+
body
|
|
2576
|
+
} = program;
|
|
2577
|
+
const dependencies = [];
|
|
2578
|
+
for (const node of body) {
|
|
2579
|
+
if (node.type === ImportDeclaration || node.type === ExportAllDeclaration) {
|
|
2580
|
+
const relativePath = node.source.extra.rawValue;
|
|
2581
|
+
const start = node.source.start;
|
|
2582
|
+
const end = node.source.end;
|
|
2583
|
+
// @ts-ignore
|
|
2584
|
+
dependencies.push({
|
|
2585
|
+
relativePath,
|
|
2586
|
+
code,
|
|
2587
|
+
start,
|
|
2588
|
+
end
|
|
2589
|
+
});
|
|
2590
|
+
} else if (node.type === VariableDeclaration && node.declarations && node.declarations[0] && node.declarations[0].type === VariableDeclarator && node.declarations[0].init && node.declarations[0].init.type === AwaitExpression && node.declarations[0].init.argument && node.declarations[0].init.argument.type === CallExpression && node.declarations[0].init.argument.callee && node.declarations[0].init.argument.callee.type === Import && node.declarations[0].init.argument.arguments && node.declarations[0].init.argument.arguments[0] && node.declarations[0].init.argument.arguments[0].type === StringLiteral) {
|
|
2591
|
+
const relativePath = node.declarations[0].init.argument.arguments[0].extra.rawValue;
|
|
2592
|
+
const start = node.declarations[0].init.argument.arguments[0].start;
|
|
2593
|
+
const end = node.declarations[0].init.argument.arguments[0].end;
|
|
2594
|
+
// @ts-ignore
|
|
2595
|
+
dependencies.push({
|
|
2596
|
+
relativePath,
|
|
2597
|
+
code,
|
|
2598
|
+
start,
|
|
2599
|
+
end
|
|
2600
|
+
});
|
|
2601
|
+
}
|
|
2602
|
+
}
|
|
2603
|
+
const visitor = node => {
|
|
2604
|
+
if (node && node.type === CallExpression && node.callee && node.callee.type === Import && node.arguments && node.arguments[0] && node.arguments[0].type === StringLiteral) {
|
|
2605
|
+
const relativePath = node.arguments[0].extra.rawValue;
|
|
2606
|
+
const start = node.arguments[0].start;
|
|
2607
|
+
const end = node.arguments[0].end;
|
|
2608
|
+
// @ts-ignore
|
|
2609
|
+
dependencies.push({
|
|
2610
|
+
relativePath,
|
|
2611
|
+
code,
|
|
2612
|
+
start,
|
|
2613
|
+
end
|
|
2614
|
+
});
|
|
2615
|
+
}
|
|
2616
|
+
};
|
|
2617
|
+
walk(ast, visitor);
|
|
2618
|
+
return dependencies;
|
|
2619
|
+
};
|
|
2620
|
+
|
|
2621
|
+
const isBabelError = error => {
|
|
2622
|
+
// @ts-ignore
|
|
2623
|
+
return isSyntaxError(error) && error.code === BABEL_PARSER_SYNTAX_ERROR;
|
|
2624
|
+
};
|
|
2625
|
+
|
|
2626
|
+
const getOrigin = () => {
|
|
2627
|
+
return location.origin;
|
|
2628
|
+
};
|
|
2629
|
+
|
|
2630
|
+
const getAbsoluteUrl = (relativePath, sourceUrl) => {
|
|
2631
|
+
if (sourceUrl.startsWith('/')) {
|
|
2632
|
+
const origin = getOrigin();
|
|
2633
|
+
const absoluteSourceUrl = new URL(sourceUrl, origin).toString();
|
|
2634
|
+
return new URL(relativePath, absoluteSourceUrl).toString();
|
|
2635
|
+
}
|
|
2636
|
+
return new URL(relativePath, sourceUrl).toString();
|
|
2637
|
+
};
|
|
2638
|
+
|
|
2639
|
+
const isExternal = url => {
|
|
2640
|
+
if (url.startsWith('/')) {
|
|
2641
|
+
return false;
|
|
2642
|
+
}
|
|
2643
|
+
if (url.startsWith(location.protocol)) {
|
|
2644
|
+
return false;
|
|
2645
|
+
}
|
|
2646
|
+
return true;
|
|
2647
|
+
};
|
|
2648
|
+
const getErrorInDependencies = async (url, dependencies, seenUrls) => {
|
|
2649
|
+
for (const dependency of dependencies) {
|
|
2650
|
+
const dependencyUrl = getAbsoluteUrl(dependency.relativePath, url);
|
|
2651
|
+
if (isExternal(dependencyUrl) || seenUrls.includes(dependencyUrl)) {
|
|
2652
|
+
continue;
|
|
2653
|
+
}
|
|
2654
|
+
seenUrls.push(dependencyUrl);
|
|
2655
|
+
// let dependencyResponse
|
|
2656
|
+
// try {
|
|
2657
|
+
const dependencyResponse = await fetch(dependencyUrl);
|
|
2658
|
+
// } catch (error) {}
|
|
2659
|
+
if (dependencyResponse.ok) {
|
|
2660
|
+
await tryToGetActualErrorMessage(null, dependencyUrl, dependencyResponse, seenUrls);
|
|
2661
|
+
} else {
|
|
2662
|
+
switch (dependencyResponse.status) {
|
|
2663
|
+
case NotFound:
|
|
2664
|
+
throw new DependencyNotFoundError(dependency.code, dependency.start, dependency.end, dependency.relativePath, dependencyUrl, url);
|
|
2665
|
+
// return `Failed to import ${url}: ${error}`
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2668
|
+
}
|
|
2669
|
+
};
|
|
2670
|
+
|
|
2671
|
+
/**
|
|
2672
|
+
*
|
|
2673
|
+
* @param {string} url
|
|
2674
|
+
* @param {Response} response
|
|
2675
|
+
* @returns
|
|
2676
|
+
*/
|
|
2677
|
+
const tryToGetActualErrorMessage = async (error, url, response, seenUrls = []) => {
|
|
2678
|
+
let text;
|
|
2679
|
+
try {
|
|
2680
|
+
text = await response.text();
|
|
2681
|
+
} catch (error) {
|
|
2682
|
+
return `Failed to import ${url}: Unknown Network Error`;
|
|
2683
|
+
}
|
|
2684
|
+
let ast;
|
|
2685
|
+
try {
|
|
2686
|
+
ast = await parse(text, {
|
|
2687
|
+
sourceType: Module
|
|
2688
|
+
});
|
|
2689
|
+
} catch (error) {
|
|
2690
|
+
if (isBabelError(error)) {
|
|
2691
|
+
throw new BabelParseError(url, error);
|
|
2692
|
+
}
|
|
2693
|
+
throw error;
|
|
2694
|
+
}
|
|
2695
|
+
const dependencies = getBabelAstDependencies(text, ast);
|
|
2696
|
+
await getErrorInDependencies(url, dependencies, seenUrls);
|
|
2697
|
+
if (hasRecentErrors()) {
|
|
2698
|
+
const recentError = getRecentError();
|
|
2699
|
+
// @ts-ignore
|
|
2700
|
+
throw new ContentSecurityPolicyError(recentError.violatedDirective, recentError.sourceFile, recentError.lineNumber, recentError.columnNumber);
|
|
2701
|
+
}
|
|
2702
|
+
const contentType = response.headers.get('Content-Type');
|
|
2703
|
+
if (url.endsWith('.ts') && contentType === null) {
|
|
2704
|
+
return `Failed to import ${url}: Missing Content-Type header for javascript`;
|
|
2705
|
+
}
|
|
2706
|
+
return `Failed to import ${url}: Unknown Network Error`;
|
|
2707
|
+
};
|
|
2708
|
+
|
|
2709
|
+
const tryToGetActualImportErrorMessage = async (url, error) => {
|
|
2710
|
+
let response;
|
|
2711
|
+
try {
|
|
2712
|
+
response = await fetch(url);
|
|
2713
|
+
} catch (error) {
|
|
2714
|
+
return `Failed to import ${url}: ${error}`;
|
|
2715
|
+
}
|
|
2716
|
+
if (response.ok) {
|
|
2717
|
+
return await tryToGetActualErrorMessage(error, url, response);
|
|
2718
|
+
}
|
|
2719
|
+
switch (response.status) {
|
|
2720
|
+
case NotFound:
|
|
2721
|
+
throw new Error(`Failed to import ${url}: Not found (404)`);
|
|
2722
|
+
default:
|
|
2723
|
+
return `Failed to import ${url}: ${error}`;
|
|
2724
|
+
}
|
|
2725
|
+
};
|
|
2726
|
+
|
|
2727
|
+
const importScript = async url => {
|
|
2728
|
+
try {
|
|
2729
|
+
return await import(url);
|
|
2730
|
+
} catch (error) {
|
|
2731
|
+
if (isImportError(error)) {
|
|
2732
|
+
const actualErrorMessage = await tryToGetActualImportErrorMessage(url, error);
|
|
2733
|
+
throw new Error(actualErrorMessage);
|
|
2734
|
+
}
|
|
2735
|
+
// content security policy errors arrive a little bit later
|
|
2736
|
+
await sleep(0);
|
|
2737
|
+
if (hasRecentErrors()) {
|
|
2738
|
+
const recentError = getRecentError();
|
|
2739
|
+
// @ts-ignore
|
|
2740
|
+
throw new ContentSecurityPolicyError(recentError.violatedDirective, recentError.sourceFile, recentError.lineNumber, recentError.columnNumber);
|
|
2741
|
+
}
|
|
2742
|
+
throw error;
|
|
2743
|
+
}
|
|
2744
|
+
};
|
|
2745
|
+
|
|
2746
|
+
const activationTimeout = 10_000;
|
|
2747
|
+
const rejectAfterTimeout = async (timeout, token) => {
|
|
2748
|
+
await sleep(timeout);
|
|
2749
|
+
if (isCanceled(token)) {
|
|
2750
|
+
return;
|
|
2751
|
+
}
|
|
2752
|
+
throw new Error(`Activation timeout of ${timeout}ms exceeded`);
|
|
2753
|
+
};
|
|
2754
|
+
const activate = async (extension, absolutePath) => {
|
|
2755
|
+
try {
|
|
2756
|
+
string(extension.path);
|
|
2757
|
+
string(extension.browser);
|
|
2758
|
+
string(absolutePath);
|
|
2759
|
+
const module = await importScript(absolutePath);
|
|
2760
|
+
handleRpcInfos(extension);
|
|
2761
|
+
const token = create$5();
|
|
2762
|
+
try {
|
|
2763
|
+
await Promise.race([module.activate(extension), rejectAfterTimeout(activationTimeout, token)]);
|
|
2764
|
+
} catch (error) {
|
|
2765
|
+
if (isImportError(error)) {
|
|
2766
|
+
const actualErrorMessage = await tryToGetActualImportErrorMessage(absolutePath, error);
|
|
2767
|
+
throw new Error(actualErrorMessage);
|
|
2768
|
+
}
|
|
2769
|
+
throw error;
|
|
2770
|
+
} finally {
|
|
2771
|
+
cancel(token);
|
|
2772
|
+
}
|
|
2773
|
+
} catch (error) {
|
|
2774
|
+
const id = getExtensionId(extension);
|
|
2775
|
+
throw new VError$1(error, `Failed to activate extension ${id}`);
|
|
2776
|
+
}
|
|
2777
|
+
// console.info('activated', path)
|
|
2778
|
+
};
|
|
2779
|
+
|
|
2780
|
+
class ExecError extends Error {
|
|
2781
|
+
constructor(command, args, stdout, stderr, exitCode) {
|
|
2782
|
+
super(`Failed to execute ${command}: process exited with code ${exitCode}`);
|
|
2783
|
+
this.name = 'ExecError';
|
|
2784
|
+
// @ts-ignore
|
|
2785
|
+
this.stdout = stdout;
|
|
2786
|
+
// @ts-ignore
|
|
2787
|
+
this.stderr = stderr;
|
|
2788
|
+
// @ts-ignore
|
|
2789
|
+
this.exitCode = exitCode;
|
|
2790
|
+
}
|
|
2791
|
+
}
|
|
2792
|
+
|
|
2793
|
+
const mockExec = () => {
|
|
2794
|
+
try {
|
|
2795
|
+
// @ts-ignore
|
|
2796
|
+
api.exec = async (command, args, options) => {
|
|
2797
|
+
const result = await invoke('Test.executeMockExecFunction', command, args, options);
|
|
2798
|
+
const {
|
|
2799
|
+
stdout,
|
|
2800
|
+
stderr,
|
|
2801
|
+
exitCode
|
|
2802
|
+
} = result;
|
|
2803
|
+
if (exitCode !== 0) {
|
|
2804
|
+
throw new ExecError(command, args, stdout, stderr, exitCode);
|
|
2805
|
+
}
|
|
2806
|
+
return {
|
|
2807
|
+
stdout,
|
|
2808
|
+
stderr,
|
|
2809
|
+
exitCode
|
|
2810
|
+
};
|
|
2811
|
+
};
|
|
2812
|
+
} catch (error) {
|
|
2813
|
+
throw new VError$1(error, 'Failed to mock exec function');
|
|
2814
|
+
}
|
|
2815
|
+
};
|
|
2816
|
+
|
|
2817
|
+
const mockRpc = () => {
|
|
2818
|
+
// @ts-ignore
|
|
2819
|
+
api.createNodeRpc = async options => {
|
|
2820
|
+
try {
|
|
2821
|
+
return {
|
|
2822
|
+
async invoke(method, ...params) {
|
|
2823
|
+
const result = await invoke('Test.executeMockRpcFunction', options.name, method, ...params);
|
|
2824
|
+
return result;
|
|
2825
|
+
}
|
|
2826
|
+
};
|
|
2827
|
+
} catch (error) {
|
|
2828
|
+
throw new VError$1(error, 'Failed to mock exec function');
|
|
2829
|
+
}
|
|
2830
|
+
};
|
|
2831
|
+
};
|
|
2832
|
+
|
|
2833
|
+
const getStatusBarItems = async () => {
|
|
2834
|
+
const providers = Object.values(state$3.providers);
|
|
2835
|
+
const statusBarItems = [];
|
|
2836
|
+
for (const provider of providers) {
|
|
2837
|
+
// @ts-ignore
|
|
2838
|
+
if (provider && provider.statusBarCommands) {
|
|
2839
|
+
// @ts-ignore
|
|
2840
|
+
statusBarItems.push(...provider.statusBarCommands);
|
|
2841
|
+
}
|
|
2842
|
+
}
|
|
2843
|
+
return statusBarItems;
|
|
2844
|
+
};
|
|
2845
|
+
const registerChangeListener = () => {
|
|
2846
|
+
// TODO
|
|
2847
|
+
};
|
|
1725
2848
|
|
|
1726
2849
|
const MessagePort$1 = 1;
|
|
1727
2850
|
const ModuleWorker = 2;
|
|
@@ -2177,6 +3300,69 @@ const getModule$1 = method => {
|
|
|
2177
3300
|
}
|
|
2178
3301
|
};
|
|
2179
3302
|
|
|
3303
|
+
const handleMessagePort = port => {
|
|
3304
|
+
const module = getModule$1(MessagePort$1);
|
|
3305
|
+
const ipc = module.wrap(port);
|
|
3306
|
+
handleIpc(ipc);
|
|
3307
|
+
ipc.send('ready');
|
|
3308
|
+
};
|
|
3309
|
+
|
|
3310
|
+
const commandMap = {
|
|
3311
|
+
['ExtensionHostDebug.evaluate']: evaluate,
|
|
3312
|
+
['ExtensionHostDebug.getProperties']: getProperties,
|
|
3313
|
+
['ExtensionHostDebug.listProcesses']: listProcesses,
|
|
3314
|
+
['ExtensionHostDebug.pause']: pause,
|
|
3315
|
+
['ExtensionHostDebug.resume']: resume,
|
|
3316
|
+
['ExtensionHostDebug.setPauseOnException']: setPauseOnException,
|
|
3317
|
+
['ExtensionHostDebug.setPauseOnExceptions']: setPauseOnExceptions,
|
|
3318
|
+
['ExtensionHostDebug.start']: start,
|
|
3319
|
+
['ExtensionHostDebug.stepInto']: stepInto,
|
|
3320
|
+
['ExtensionHostDebug.stepOut']: stepOut,
|
|
3321
|
+
['ExtensionHostDebug.stepOver']: stepOver,
|
|
3322
|
+
['ExtensionHostWebView.create']: createWebView,
|
|
3323
|
+
['ExtensionHostWebView.dispose']: disposeWebView,
|
|
3324
|
+
['ExtensionHostWebView.load']: load,
|
|
3325
|
+
['HandleMessagePort.handleMessagePort']: handleMessagePort,
|
|
3326
|
+
[BraceCompletionExecuteBraceCompletionProvider]: executeBraceCompletionProvider,
|
|
3327
|
+
[ClosingTagExecuteClosingTagProvider]: executeClosingTagProvider,
|
|
3328
|
+
[CommandExecute]: executeCommand,
|
|
3329
|
+
[CompletionExecute]: executeCompletionProvider,
|
|
3330
|
+
[CompletionResolveExecute]: executeresolveCompletionItemProvider,
|
|
3331
|
+
[ConfigurationSetConfiguration]: setConfigurations,
|
|
3332
|
+
[DefinitionExecuteDefinitionProvider]: executeDefinitionProvider,
|
|
3333
|
+
[DiagnosticExecuteDiagnosticProvider]: executeDiagnosticProvider,
|
|
3334
|
+
[ExtensionActivate]: activate,
|
|
3335
|
+
[FileSystemGetPathSeparator]: getPathSeparator,
|
|
3336
|
+
[FileSystemReadDirWithFileTypes]: readDirWithFileTypes,
|
|
3337
|
+
[FileSystemReadFile]: readFile,
|
|
3338
|
+
[FileSystemWriteFile]: writeFile,
|
|
3339
|
+
[FormattingExecuteFormmattingProvider]: executeFormattingProvider,
|
|
3340
|
+
[HoverExecute]: executeHoverProvider,
|
|
3341
|
+
[ImplementationExecuteImplementationProvider]: executeImplementationProvider,
|
|
3342
|
+
[MockExec]: mockExec,
|
|
3343
|
+
[MockRpc]: mockRpc,
|
|
3344
|
+
[OrganizeImportsExecute]: executeOrganizeImports,
|
|
3345
|
+
[ReferenceExecuteFileReferenceProvider]: executefileReferenceProvider,
|
|
3346
|
+
[ReferenceExecuteReferenceProvider]: executeReferenceProvider,
|
|
3347
|
+
[SelectionExecuteSelectionProvider]: executeSelectionProvider,
|
|
3348
|
+
[SourceControlAcceptInput]: acceptInput,
|
|
3349
|
+
[SourceControlAdd]: add,
|
|
3350
|
+
[SourceControlDiscard]: discard,
|
|
3351
|
+
[SourceControlGetChangedFiles]: getChangedFiles,
|
|
3352
|
+
[SourceControlGetEnabledProviderIds]: getEnabledProviderIds,
|
|
3353
|
+
[SourceControlGetFileBefore]: getFileBefore,
|
|
3354
|
+
[SourceControlGetGroups]: getGroups,
|
|
3355
|
+
[StatusBarGetStatusBarItems]: getStatusBarItems,
|
|
3356
|
+
[StatusBarRegisterChangeListener]: registerChangeListener,
|
|
3357
|
+
[TabCompletionExecuteTabCompletionProvider]: executeTabCompletionProvider,
|
|
3358
|
+
[TextDocumentSetLanguageId]: setLanguageId,
|
|
3359
|
+
[TextDocumentSyncFull]: syncFull,
|
|
3360
|
+
[TextDocumentSyncIncremental]: syncIncremental,
|
|
3361
|
+
[TextSearchExecuteTextSearchProvider]: executeTextSearchProvider,
|
|
3362
|
+
[TypeDefinitionExecuteTypeDefinitionProvider]: executeTypeDefinitionProvider,
|
|
3363
|
+
[WorkspaceSetPath]: setWorkspacePath
|
|
3364
|
+
};
|
|
3365
|
+
|
|
2180
3366
|
const handleError = async error => {
|
|
2181
3367
|
console.error(error);
|
|
2182
3368
|
};
|
|
@@ -2206,6 +3392,18 @@ const handleUnhandledError = async event => {
|
|
|
2206
3392
|
};
|
|
2207
3393
|
|
|
2208
3394
|
const handleContentSecurityPolicyViolation = event => {
|
|
3395
|
+
const {
|
|
3396
|
+
violatedDirective,
|
|
3397
|
+
sourceFile,
|
|
3398
|
+
lineNumber,
|
|
3399
|
+
columnNumber
|
|
3400
|
+
} = event;
|
|
3401
|
+
addError({
|
|
3402
|
+
violatedDirective,
|
|
3403
|
+
sourceFile,
|
|
3404
|
+
lineNumber,
|
|
3405
|
+
columnNumber
|
|
3406
|
+
});
|
|
2209
3407
|
};
|
|
2210
3408
|
|
|
2211
3409
|
const listen = async ({
|
|
@@ -2236,8 +3434,7 @@ const main = async () => {
|
|
|
2236
3434
|
self.addEventListener('securitypolicyviolation', handleContentSecurityPolicyViolation);
|
|
2237
3435
|
}
|
|
2238
3436
|
globalThis.vscode = api;
|
|
2239
|
-
|
|
2240
|
-
undefined.getFn = undefined;
|
|
3437
|
+
register(commandMap);
|
|
2241
3438
|
const ipc = await listen({
|
|
2242
3439
|
method: Auto()
|
|
2243
3440
|
});
|
|
@@ -2435,7 +3632,7 @@ const create$2 = async ({
|
|
|
2435
3632
|
port1,
|
|
2436
3633
|
port2
|
|
2437
3634
|
} = getPortTuple();
|
|
2438
|
-
await invokeAndTransfer(
|
|
3635
|
+
await invokeAndTransfer('IpcParent.create', {
|
|
2439
3636
|
method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug,
|
|
2440
3637
|
url,
|
|
2441
3638
|
name,
|