@codingame/monaco-vscode-api 1.76.2 → 1.76.3-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +2 -1
  2. package/dist/api.js +3 -860
  3. package/dist/{extHost.js → api2.js} +16555 -13467
  4. package/dist/async.js +107 -2
  5. package/dist/audioCue.js +105 -103
  6. package/dist/button.js +1 -1
  7. package/dist/cancellation.js +3 -0
  8. package/dist/configuration.js +7 -344
  9. package/dist/configuration2.js +339 -0
  10. package/dist/configurationRegistry.js +441 -0
  11. package/dist/contextkeys.js +211 -0
  12. package/dist/debug.d.ts +22 -0
  13. package/dist/debug.js +15842 -0
  14. package/dist/dialogs.js +855 -9
  15. package/dist/extensionResourceLoader.js +96 -0
  16. package/dist/extensions.d.ts +491 -0
  17. package/dist/extensions.js +70 -0
  18. package/dist/{tools.js → extensionsRegistry.js} +2 -30
  19. package/dist/files.js +1407 -334
  20. package/dist/iconv.js +43 -0
  21. package/dist/injection.js +1 -1
  22. package/dist/jschardet.js +7 -0
  23. package/dist/keybindings.d.ts +1 -485
  24. package/dist/keybindings.js +666 -679
  25. package/dist/labels.js +14 -0
  26. package/dist/languageConfiguration.d.ts +1 -2
  27. package/dist/languageConfiguration.js +9 -16
  28. package/dist/languageService.js +112 -8
  29. package/dist/languages.d.ts +1 -473
  30. package/dist/languages.js +2 -12
  31. package/dist/layout.js +4 -3
  32. package/dist/layoutService.js +1 -1
  33. package/dist/missing-services.js +4710 -74
  34. package/dist/modelEditor.d.ts +324 -2
  35. package/dist/modelEditor.js +15 -228
  36. package/dist/monaco.js +7 -72
  37. package/dist/notifications.js +75 -232
  38. package/dist/polyfill.js +10715 -2459
  39. package/dist/resources.js +197 -0
  40. package/dist/services.d.ts +924 -3
  41. package/dist/services.js +1 -2
  42. package/dist/services2.js +2436 -18
  43. package/dist/snippets.d.ts +1 -473
  44. package/dist/snippets.js +8 -867
  45. package/dist/snippetsService.js +868 -0
  46. package/dist/textFileEditorModel.js +2985 -0
  47. package/dist/textmate.d.ts +3 -475
  48. package/dist/textmate.js +19 -29
  49. package/dist/theme.d.ts +1 -3
  50. package/dist/theme.js +24 -70
  51. package/dist/tokenClassification.d.ts +1 -475
  52. package/dist/tokenClassification.js +11 -37
  53. package/dist/tokenClassificationRegistry.js +8 -4
  54. package/dist/variableResolver.js +1711 -0
  55. package/dist/workbenchThemeService.js +1 -1
  56. package/dist/workspaceContext.js +1 -3
  57. package/package.json +27 -12
  58. package/dist/contextkey.js +0 -419
  59. package/dist/dialog.web.contribution.js +0 -945
@@ -0,0 +1,339 @@
1
+ import { X as parseTree, Y as findNodeAtLocation, Z as createScanner } from './polyfill.js';
2
+ function format(documentText, range, options) {
3
+ let initialIndentLevel;
4
+ let formatText;
5
+ let formatTextStart;
6
+ let rangeStart;
7
+ let rangeEnd;
8
+ if (range) {
9
+ rangeStart = range.offset;
10
+ rangeEnd = rangeStart + range.length;
11
+ formatTextStart = rangeStart;
12
+ while (formatTextStart > 0 && !isEOL(documentText, formatTextStart - 1)) {
13
+ formatTextStart--;
14
+ }
15
+ let endOffset = rangeEnd;
16
+ while (endOffset < documentText.length && !isEOL(documentText, endOffset)) {
17
+ endOffset++;
18
+ }
19
+ formatText = documentText.substring(formatTextStart, endOffset);
20
+ initialIndentLevel = computeIndentLevel(formatText, options);
21
+ }
22
+ else {
23
+ formatText = documentText;
24
+ initialIndentLevel = 0;
25
+ formatTextStart = 0;
26
+ rangeStart = 0;
27
+ rangeEnd = documentText.length;
28
+ }
29
+ const eol = getEOL(options, documentText);
30
+ let lineBreak = false;
31
+ let indentLevel = 0;
32
+ let indentValue;
33
+ if (options.insertSpaces) {
34
+ indentValue = repeat(' ', options.tabSize || 4);
35
+ }
36
+ else {
37
+ indentValue = '\t';
38
+ }
39
+ const scanner = createScanner(formatText, false);
40
+ let hasError = false;
41
+ function newLineAndIndent() {
42
+ return eol + repeat(indentValue, initialIndentLevel + indentLevel);
43
+ }
44
+ function scanNext() {
45
+ let token = scanner.scan();
46
+ lineBreak = false;
47
+ while (token === 15 || token === 14 ) {
48
+ lineBreak = lineBreak || (token === 14 );
49
+ token = scanner.scan();
50
+ }
51
+ hasError = token === 16 || scanner.getTokenError() !== 0 ;
52
+ return token;
53
+ }
54
+ const editOperations = [];
55
+ function addEdit(text, startOffset, endOffset) {
56
+ if (!hasError && startOffset < rangeEnd && endOffset > rangeStart && documentText.substring(startOffset, endOffset) !== text) {
57
+ editOperations.push({ offset: startOffset, length: endOffset - startOffset, content: text });
58
+ }
59
+ }
60
+ let firstToken = scanNext();
61
+ if (firstToken !== 17 ) {
62
+ const firstTokenStart = scanner.getTokenOffset() + formatTextStart;
63
+ const initialIndent = repeat(indentValue, initialIndentLevel);
64
+ addEdit(initialIndent, formatTextStart, firstTokenStart);
65
+ }
66
+ while (firstToken !== 17 ) {
67
+ let firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
68
+ let secondToken = scanNext();
69
+ let replaceContent = '';
70
+ while (!lineBreak && (secondToken === 12 || secondToken === 13 )) {
71
+ const commentTokenStart = scanner.getTokenOffset() + formatTextStart;
72
+ addEdit(' ', firstTokenEnd, commentTokenStart);
73
+ firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
74
+ replaceContent = secondToken === 12 ? newLineAndIndent() : '';
75
+ secondToken = scanNext();
76
+ }
77
+ if (secondToken === 2 ) {
78
+ if (firstToken !== 1 ) {
79
+ indentLevel--;
80
+ replaceContent = newLineAndIndent();
81
+ }
82
+ }
83
+ else if (secondToken === 4 ) {
84
+ if (firstToken !== 3 ) {
85
+ indentLevel--;
86
+ replaceContent = newLineAndIndent();
87
+ }
88
+ }
89
+ else {
90
+ switch (firstToken) {
91
+ case 3 :
92
+ case 1 :
93
+ indentLevel++;
94
+ replaceContent = newLineAndIndent();
95
+ break;
96
+ case 5 :
97
+ case 12 :
98
+ replaceContent = newLineAndIndent();
99
+ break;
100
+ case 13 :
101
+ if (lineBreak) {
102
+ replaceContent = newLineAndIndent();
103
+ }
104
+ else {
105
+ replaceContent = ' ';
106
+ }
107
+ break;
108
+ case 6 :
109
+ replaceContent = ' ';
110
+ break;
111
+ case 10 :
112
+ if (secondToken === 6 ) {
113
+ replaceContent = '';
114
+ break;
115
+ }
116
+ case 7 :
117
+ case 8 :
118
+ case 9 :
119
+ case 11 :
120
+ case 2 :
121
+ case 4 :
122
+ if (secondToken === 12 || secondToken === 13 ) {
123
+ replaceContent = ' ';
124
+ }
125
+ else if (secondToken !== 5 && secondToken !== 17 ) {
126
+ hasError = true;
127
+ }
128
+ break;
129
+ case 16 :
130
+ hasError = true;
131
+ break;
132
+ }
133
+ if (lineBreak && (secondToken === 12 || secondToken === 13 )) {
134
+ replaceContent = newLineAndIndent();
135
+ }
136
+ }
137
+ const secondTokenStart = scanner.getTokenOffset() + formatTextStart;
138
+ addEdit(replaceContent, firstTokenEnd, secondTokenStart);
139
+ firstToken = secondToken;
140
+ }
141
+ return editOperations;
142
+ }
143
+ function repeat(s, count) {
144
+ let result = '';
145
+ for (let i = 0; i < count; i++) {
146
+ result += s;
147
+ }
148
+ return result;
149
+ }
150
+ function computeIndentLevel(content, options) {
151
+ let i = 0;
152
+ let nChars = 0;
153
+ const tabSize = options.tabSize || 4;
154
+ while (i < content.length) {
155
+ const ch = content.charAt(i);
156
+ if (ch === ' ') {
157
+ nChars++;
158
+ }
159
+ else if (ch === '\t') {
160
+ nChars += tabSize;
161
+ }
162
+ else {
163
+ break;
164
+ }
165
+ i++;
166
+ }
167
+ return Math.floor(nChars / tabSize);
168
+ }
169
+ function getEOL(options, text) {
170
+ for (let i = 0; i < text.length; i++) {
171
+ const ch = text.charAt(i);
172
+ if (ch === '\r') {
173
+ if (i + 1 < text.length && text.charAt(i + 1) === '\n') {
174
+ return '\r\n';
175
+ }
176
+ return '\r';
177
+ }
178
+ else if (ch === '\n') {
179
+ return '\n';
180
+ }
181
+ }
182
+ return (options && options.eol) || '\n';
183
+ }
184
+ function isEOL(text, offset) {
185
+ return '\r\n'.indexOf(text.charAt(offset)) !== -1;
186
+ }
187
+ function setProperty(text, originalPath, value, formattingOptions, getInsertionIndex) {
188
+ const path = originalPath.slice();
189
+ const errors = [];
190
+ const root = parseTree(text, errors);
191
+ let parent = undefined;
192
+ let lastSegment = undefined;
193
+ while (path.length > 0) {
194
+ lastSegment = path.pop();
195
+ parent = findNodeAtLocation(root, path);
196
+ if (parent === undefined && value !== undefined) {
197
+ if (typeof lastSegment === 'string') {
198
+ value = { [lastSegment]: value };
199
+ }
200
+ else {
201
+ value = [value];
202
+ }
203
+ }
204
+ else {
205
+ break;
206
+ }
207
+ }
208
+ if (!parent) {
209
+ if (value === undefined) {
210
+ throw new Error('Can not delete in empty document');
211
+ }
212
+ return withFormatting(text, { offset: root ? root.offset : 0, length: root ? root.length : 0, content: JSON.stringify(value) }, formattingOptions);
213
+ }
214
+ else if (parent.type === 'object' && typeof lastSegment === 'string' && Array.isArray(parent.children)) {
215
+ const existing = findNodeAtLocation(parent, [lastSegment]);
216
+ if (existing !== undefined) {
217
+ if (value === undefined) {
218
+ if (!existing.parent) {
219
+ throw new Error('Malformed AST');
220
+ }
221
+ const propertyIndex = parent.children.indexOf(existing.parent);
222
+ let removeBegin;
223
+ let removeEnd = existing.parent.offset + existing.parent.length;
224
+ if (propertyIndex > 0) {
225
+ const previous = parent.children[propertyIndex - 1];
226
+ removeBegin = previous.offset + previous.length;
227
+ }
228
+ else {
229
+ removeBegin = parent.offset + 1;
230
+ if (parent.children.length > 1) {
231
+ const next = parent.children[1];
232
+ removeEnd = next.offset;
233
+ }
234
+ }
235
+ return withFormatting(text, { offset: removeBegin, length: removeEnd - removeBegin, content: '' }, formattingOptions);
236
+ }
237
+ else {
238
+ return withFormatting(text, { offset: existing.offset, length: existing.length, content: JSON.stringify(value) }, formattingOptions);
239
+ }
240
+ }
241
+ else {
242
+ if (value === undefined) {
243
+ return [];
244
+ }
245
+ const newProperty = `${JSON.stringify(lastSegment)}: ${JSON.stringify(value)}`;
246
+ const index = getInsertionIndex ? getInsertionIndex(( parent.children.map(p => p.children[0].value))) : parent.children.length;
247
+ let edit;
248
+ if (index > 0) {
249
+ const previous = parent.children[index - 1];
250
+ edit = { offset: previous.offset + previous.length, length: 0, content: ',' + newProperty };
251
+ }
252
+ else if (parent.children.length === 0) {
253
+ edit = { offset: parent.offset + 1, length: 0, content: newProperty };
254
+ }
255
+ else {
256
+ edit = { offset: parent.offset + 1, length: 0, content: newProperty + ',' };
257
+ }
258
+ return withFormatting(text, edit, formattingOptions);
259
+ }
260
+ }
261
+ else if (parent.type === 'array' && typeof lastSegment === 'number' && Array.isArray(parent.children)) {
262
+ if (value !== undefined) {
263
+ const newProperty = `${JSON.stringify(value)}`;
264
+ let edit;
265
+ if (parent.children.length === 0 || lastSegment === 0) {
266
+ edit = { offset: parent.offset + 1, length: 0, content: parent.children.length === 0 ? newProperty : newProperty + ',' };
267
+ }
268
+ else {
269
+ const index = lastSegment === -1 || lastSegment > parent.children.length ? parent.children.length : lastSegment;
270
+ const previous = parent.children[index - 1];
271
+ edit = { offset: previous.offset + previous.length, length: 0, content: ',' + newProperty };
272
+ }
273
+ return withFormatting(text, edit, formattingOptions);
274
+ }
275
+ else {
276
+ const removalIndex = lastSegment;
277
+ const toRemove = parent.children[removalIndex];
278
+ let edit;
279
+ if (parent.children.length === 1) {
280
+ edit = { offset: parent.offset + 1, length: parent.length - 2, content: '' };
281
+ }
282
+ else if (parent.children.length - 1 === removalIndex) {
283
+ const previous = parent.children[removalIndex - 1];
284
+ const offset = previous.offset + previous.length;
285
+ const parentEndOffset = parent.offset + parent.length;
286
+ edit = { offset, length: parentEndOffset - 2 - offset, content: '' };
287
+ }
288
+ else {
289
+ edit = { offset: toRemove.offset, length: parent.children[removalIndex + 1].offset - toRemove.offset, content: '' };
290
+ }
291
+ return withFormatting(text, edit, formattingOptions);
292
+ }
293
+ }
294
+ else {
295
+ throw new Error(`Can not add ${typeof lastSegment !== 'number' ? 'index' : 'property'} to parent of type ${parent.type}`);
296
+ }
297
+ }
298
+ function withFormatting(text, edit, formattingOptions) {
299
+ let newText = applyEdit(text, edit);
300
+ let begin = edit.offset;
301
+ let end = edit.offset + edit.content.length;
302
+ if (edit.length === 0 || edit.content.length === 0) {
303
+ while (begin > 0 && !isEOL(newText, begin - 1)) {
304
+ begin--;
305
+ }
306
+ while (end < newText.length && !isEOL(newText, end)) {
307
+ end++;
308
+ }
309
+ }
310
+ const edits = format(newText, { offset: begin, length: end - begin }, formattingOptions);
311
+ for (let i = edits.length - 1; i >= 0; i--) {
312
+ const curr = edits[i];
313
+ newText = applyEdit(newText, curr);
314
+ begin = Math.min(begin, curr.offset);
315
+ end = Math.max(end, curr.offset + curr.length);
316
+ end += curr.content.length - curr.length;
317
+ }
318
+ const editLength = text.length - (newText.length - end) - begin;
319
+ return [{ offset: begin, length: editLength, content: newText.substring(begin, end) }];
320
+ }
321
+ function applyEdit(text, edit) {
322
+ return text.substring(0, edit.offset) + edit.content + text.substring(edit.offset + edit.length);
323
+ }
324
+ const FOLDER_CONFIG_FOLDER_NAME = '.vscode';
325
+ const defaultSettingsSchemaId = 'vscode://schemas/settings/default';
326
+ const userSettingsSchemaId = 'vscode://schemas/settings/user';
327
+ const profileSettingsSchemaId = 'vscode://schemas/settings/profile';
328
+ const machineSettingsSchemaId = 'vscode://schemas/settings/machine';
329
+ const workspaceSettingsSchemaId = 'vscode://schemas/settings/workspace';
330
+ const folderSettingsSchemaId = 'vscode://schemas/settings/folder';
331
+ const launchSchemaId = 'vscode://schemas/launch';
332
+ const TASKS_CONFIGURATION_KEY = 'tasks';
333
+ const LAUNCH_CONFIGURATION_KEY = 'launch';
334
+ const WORKSPACE_STANDALONE_CONFIGURATIONS = Object.create(null);
335
+ WORKSPACE_STANDALONE_CONFIGURATIONS[TASKS_CONFIGURATION_KEY] = `${FOLDER_CONFIG_FOLDER_NAME}/${TASKS_CONFIGURATION_KEY}.json`;
336
+ WORKSPACE_STANDALONE_CONFIGURATIONS[LAUNCH_CONFIGURATION_KEY] = `${FOLDER_CONFIG_FOLDER_NAME}/${LAUNCH_CONFIGURATION_KEY}.json`;
337
+ const USER_STANDALONE_CONFIGURATIONS = Object.create(null);
338
+ USER_STANDALONE_CONFIGURATIONS[TASKS_CONFIGURATION_KEY] = `${TASKS_CONFIGURATION_KEY}.json`;
339
+ export { defaultSettingsSchemaId as d, folderSettingsSchemaId as f, launchSchemaId as l, machineSettingsSchemaId as m, profileSettingsSchemaId as p, setProperty as s, userSettingsSchemaId as u, workspaceSettingsSchemaId as w };