@codingame/monaco-vscode-api 1.68.7 → 1.69.2
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/README.md +102 -7
- package/dist/api.js +481 -9583
- package/dist/configuration.d.ts +488 -0
- package/dist/configuration.js +582 -0
- package/dist/extHost.js +14881 -0
- package/dist/files.js +1325 -0
- package/dist/injection.js +15 -0
- package/dist/jsonErrorMessages.js +17 -0
- package/dist/keybindings.d.ts +502 -0
- package/dist/keybindings.js +2352 -0
- package/dist/languageConfiguration.d.ts +8 -0
- package/dist/languageConfiguration.js +925 -0
- package/dist/languageService.js +340 -0
- package/dist/languages.d.ts +477 -0
- package/dist/languages.js +21 -0
- package/dist/layoutService.js +4 -0
- package/dist/messages.d.ts +7 -0
- package/dist/messages.js +3624 -0
- package/dist/missing-services.js +7778 -0
- package/dist/modelEditor.d.ts +164 -0
- package/dist/modelEditor.js +739 -0
- package/dist/monaco.d.ts +4914 -0
- package/dist/monaco.js +261 -0
- package/dist/services.d.ts +14806 -2098
- package/dist/services.js +22 -25
- package/dist/services2.js +423 -0
- package/dist/snippets.d.ts +466 -0
- package/dist/snippets.js +864 -0
- package/dist/textmate.d.ts +683 -0
- package/dist/textmate.js +739 -0
- package/dist/theme.d.ts +23 -0
- package/dist/theme.js +4167 -0
- package/dist/tokenClassification.d.ts +479 -0
- package/dist/tokenClassification.js +302 -0
- package/dist/tokenClassificationRegistry.js +472 -0
- package/dist/tools.js +31 -0
- package/dist/tslib.es6.js +21 -0
- package/dist/workbenchThemeService.js +46 -0
- package/dist/workspaceContext.js +49 -0
- package/package.json +107 -24
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import { _ as __decorate, a as __param } from './tslib.es6.js';
|
|
2
|
+
import { h as ExtensionsRegistry, I as IExtensionService } from './missing-services.js';
|
|
3
|
+
import { Y as FILES_ASSOCIATIONS_CONFIG } from './services2.js';
|
|
4
|
+
import { parse } from 'monaco-editor/esm/vs/base/common/glob.js';
|
|
5
|
+
import { posix } from 'monaco-editor/esm/vs/base/common/path.js';
|
|
6
|
+
import { LanguageService } from 'monaco-editor/esm/vs/editor/common/services/languageService.js';
|
|
7
|
+
import { localize } from 'monaco-editor/esm/vs/nls.js';
|
|
8
|
+
import { joinPath } from 'monaco-editor/esm/vs/base/common/resources.js';
|
|
9
|
+
import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
|
|
10
|
+
import { IEnvironmentService } from 'monaco-editor/esm/vs/platform/environment/common/environment.js';
|
|
11
|
+
import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
|
|
12
|
+
let registeredAssociations = [];
|
|
13
|
+
let userRegisteredAssociations = [];
|
|
14
|
+
function registerConfiguredLanguageAssociation(association) {
|
|
15
|
+
_registerLanguageAssociation(association, true, false);
|
|
16
|
+
}
|
|
17
|
+
function _registerLanguageAssociation(association, userConfigured, warnOnOverwrite) {
|
|
18
|
+
const associationItem = toLanguageAssociationItem(association, userConfigured);
|
|
19
|
+
registeredAssociations.push(associationItem);
|
|
20
|
+
if (!associationItem.userConfigured) ;
|
|
21
|
+
else {
|
|
22
|
+
userRegisteredAssociations.push(associationItem);
|
|
23
|
+
}
|
|
24
|
+
if (warnOnOverwrite && !associationItem.userConfigured) {
|
|
25
|
+
registeredAssociations.forEach(a => {
|
|
26
|
+
if (a.mime === associationItem.mime || a.userConfigured) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (associationItem.extension && a.extension === associationItem.extension) {
|
|
30
|
+
console.warn(`Overwriting extension <<${associationItem.extension}>> to now point to mime <<${associationItem.mime}>>`);
|
|
31
|
+
}
|
|
32
|
+
if (associationItem.filename && a.filename === associationItem.filename) {
|
|
33
|
+
console.warn(`Overwriting filename <<${associationItem.filename}>> to now point to mime <<${associationItem.mime}>>`);
|
|
34
|
+
}
|
|
35
|
+
if (associationItem.filepattern && a.filepattern === associationItem.filepattern) {
|
|
36
|
+
console.warn(`Overwriting filepattern <<${associationItem.filepattern}>> to now point to mime <<${associationItem.mime}>>`);
|
|
37
|
+
}
|
|
38
|
+
if (associationItem.firstline && a.firstline === associationItem.firstline) {
|
|
39
|
+
console.warn(`Overwriting firstline <<${associationItem.firstline}>> to now point to mime <<${associationItem.mime}>>`);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function toLanguageAssociationItem(association, userConfigured) {
|
|
45
|
+
return {
|
|
46
|
+
id: association.id,
|
|
47
|
+
mime: association.mime,
|
|
48
|
+
filename: association.filename,
|
|
49
|
+
extension: association.extension,
|
|
50
|
+
filepattern: association.filepattern,
|
|
51
|
+
firstline: association.firstline,
|
|
52
|
+
userConfigured: userConfigured,
|
|
53
|
+
filenameLowercase: association.filename ? association.filename.toLowerCase() : undefined,
|
|
54
|
+
extensionLowercase: association.extension ? association.extension.toLowerCase() : undefined,
|
|
55
|
+
filepatternLowercase: association.filepattern ? parse(association.filepattern.toLowerCase()) : undefined,
|
|
56
|
+
filepatternOnPath: association.filepattern ? association.filepattern.indexOf(posix.sep) >= 0 : false
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function clearConfiguredLanguageAssociations() {
|
|
60
|
+
registeredAssociations = registeredAssociations.filter(a => !a.userConfigured);
|
|
61
|
+
userRegisteredAssociations = [];
|
|
62
|
+
}
|
|
63
|
+
const languagesExtPoint = ( ExtensionsRegistry.registerExtensionPoint({
|
|
64
|
+
extensionPoint: 'languages',
|
|
65
|
+
jsonSchema: {
|
|
66
|
+
description: ( localize(
|
|
67
|
+
'vscode.extension.contributes.languages',
|
|
68
|
+
'Contributes language declarations.'
|
|
69
|
+
)),
|
|
70
|
+
type: 'array',
|
|
71
|
+
items: {
|
|
72
|
+
type: 'object',
|
|
73
|
+
defaultSnippets: [{ body: { id: '${1:languageId}', aliases: ['${2:label}'], extensions: ['${3:extension}'], configuration: './language-configuration.json' } }],
|
|
74
|
+
properties: {
|
|
75
|
+
id: {
|
|
76
|
+
description: ( localize('vscode.extension.contributes.languages.id', 'ID of the language.')),
|
|
77
|
+
type: 'string'
|
|
78
|
+
},
|
|
79
|
+
aliases: {
|
|
80
|
+
description: ( localize(
|
|
81
|
+
'vscode.extension.contributes.languages.aliases',
|
|
82
|
+
'Name aliases for the language.'
|
|
83
|
+
)),
|
|
84
|
+
type: 'array',
|
|
85
|
+
items: {
|
|
86
|
+
type: 'string'
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
extensions: {
|
|
90
|
+
description: ( localize(
|
|
91
|
+
'vscode.extension.contributes.languages.extensions',
|
|
92
|
+
'File extensions associated to the language.'
|
|
93
|
+
)),
|
|
94
|
+
default: ['.foo'],
|
|
95
|
+
type: 'array',
|
|
96
|
+
items: {
|
|
97
|
+
type: 'string'
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
filenames: {
|
|
101
|
+
description: ( localize(
|
|
102
|
+
'vscode.extension.contributes.languages.filenames',
|
|
103
|
+
'File names associated to the language.'
|
|
104
|
+
)),
|
|
105
|
+
type: 'array',
|
|
106
|
+
items: {
|
|
107
|
+
type: 'string'
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
filenamePatterns: {
|
|
111
|
+
description: ( localize(
|
|
112
|
+
'vscode.extension.contributes.languages.filenamePatterns',
|
|
113
|
+
'File name glob patterns associated to the language.'
|
|
114
|
+
)),
|
|
115
|
+
type: 'array',
|
|
116
|
+
items: {
|
|
117
|
+
type: 'string'
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
mimetypes: {
|
|
121
|
+
description: ( localize(
|
|
122
|
+
'vscode.extension.contributes.languages.mimetypes',
|
|
123
|
+
'Mime types associated to the language.'
|
|
124
|
+
)),
|
|
125
|
+
type: 'array',
|
|
126
|
+
items: {
|
|
127
|
+
type: 'string'
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
firstLine: {
|
|
131
|
+
description: ( localize(
|
|
132
|
+
'vscode.extension.contributes.languages.firstLine',
|
|
133
|
+
'A regular expression matching the first line of a file of the language.'
|
|
134
|
+
)),
|
|
135
|
+
type: 'string'
|
|
136
|
+
},
|
|
137
|
+
configuration: {
|
|
138
|
+
description: ( localize(
|
|
139
|
+
'vscode.extension.contributes.languages.configuration',
|
|
140
|
+
'A relative path to a file containing configuration options for the language.'
|
|
141
|
+
)),
|
|
142
|
+
type: 'string',
|
|
143
|
+
default: './language-configuration.json'
|
|
144
|
+
},
|
|
145
|
+
icon: {
|
|
146
|
+
type: 'object',
|
|
147
|
+
description: ( localize(
|
|
148
|
+
'vscode.extension.contributes.languages.icon',
|
|
149
|
+
'A icon to use as file icon, if no icon theme provides one for the language.'
|
|
150
|
+
)),
|
|
151
|
+
properties: {
|
|
152
|
+
light: {
|
|
153
|
+
description: ( localize(
|
|
154
|
+
'vscode.extension.contributes.languages.icon.light',
|
|
155
|
+
'Icon path when a light theme is used'
|
|
156
|
+
)),
|
|
157
|
+
type: 'string'
|
|
158
|
+
},
|
|
159
|
+
dark: {
|
|
160
|
+
description: ( localize(
|
|
161
|
+
'vscode.extension.contributes.languages.icon.dark',
|
|
162
|
+
'Icon path when a dark theme is used'
|
|
163
|
+
)),
|
|
164
|
+
type: 'string'
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}));
|
|
172
|
+
let WorkbenchLanguageService = class WorkbenchLanguageService extends LanguageService {
|
|
173
|
+
constructor(extensionService, configurationService, environmentService, logService) {
|
|
174
|
+
super(environmentService.verbose || environmentService.isExtensionDevelopment || !environmentService.isBuilt);
|
|
175
|
+
this.logService = logService;
|
|
176
|
+
this._configurationService = configurationService;
|
|
177
|
+
this._extensionService = extensionService;
|
|
178
|
+
languagesExtPoint.setHandler((extensions) => {
|
|
179
|
+
const allValidLanguages = [];
|
|
180
|
+
for (let i = 0, len = extensions.length; i < len; i++) {
|
|
181
|
+
const extension = extensions[i];
|
|
182
|
+
if (!Array.isArray(extension.value)) {
|
|
183
|
+
extension.collector.error(( localize(
|
|
184
|
+
'invalid',
|
|
185
|
+
"Invalid `contributes.{0}`. Expected an array.",
|
|
186
|
+
languagesExtPoint.name
|
|
187
|
+
)));
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
for (let j = 0, lenJ = extension.value.length; j < lenJ; j++) {
|
|
191
|
+
const ext = extension.value[j];
|
|
192
|
+
if (isValidLanguageExtensionPoint(ext, extension.description, extension.collector)) {
|
|
193
|
+
let configuration = undefined;
|
|
194
|
+
if (ext.configuration) {
|
|
195
|
+
configuration = joinPath(extension.description.extensionLocation, ext.configuration);
|
|
196
|
+
}
|
|
197
|
+
allValidLanguages.push({
|
|
198
|
+
id: ext.id,
|
|
199
|
+
extensions: ext.extensions,
|
|
200
|
+
filenames: ext.filenames,
|
|
201
|
+
filenamePatterns: ext.filenamePatterns,
|
|
202
|
+
firstLine: ext.firstLine,
|
|
203
|
+
aliases: ext.aliases,
|
|
204
|
+
mimetypes: ext.mimetypes,
|
|
205
|
+
configuration: configuration,
|
|
206
|
+
icon: ext.icon && {
|
|
207
|
+
light: joinPath(extension.description.extensionLocation, ext.icon.light),
|
|
208
|
+
dark: joinPath(extension.description.extensionLocation, ext.icon.dark)
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
this._registry.setDynamicLanguages(allValidLanguages);
|
|
215
|
+
});
|
|
216
|
+
this.updateMime();
|
|
217
|
+
this._configurationService.onDidChangeConfiguration(e => {
|
|
218
|
+
if (e.affectsConfiguration(FILES_ASSOCIATIONS_CONFIG)) {
|
|
219
|
+
this.updateMime();
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
this._extensionService.whenInstalledExtensionsRegistered().then(() => {
|
|
223
|
+
this.updateMime();
|
|
224
|
+
});
|
|
225
|
+
this.onDidEncounterLanguage((languageId) => {
|
|
226
|
+
this._extensionService.activateByEvent(`onLanguage:${languageId}`);
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
updateMime() {
|
|
230
|
+
const configuration = this._configurationService.getValue();
|
|
231
|
+
clearConfiguredLanguageAssociations();
|
|
232
|
+
if (configuration.files?.associations) {
|
|
233
|
+
( Object.keys(configuration.files.associations)).forEach(pattern => {
|
|
234
|
+
const langId = configuration.files.associations[pattern];
|
|
235
|
+
if (typeof langId !== 'string') {
|
|
236
|
+
this.logService.warn(`Ingnoing configured 'files.associations' for '${pattern}' because its type is not a string but '${typeof langId}'`);
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
const mimeType = this.getMimeType(langId) || `text/x-${langId}`;
|
|
240
|
+
registerConfiguredLanguageAssociation({ id: langId, mime: mimeType, filepattern: pattern });
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
this._onDidChange.fire();
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
WorkbenchLanguageService = ( __decorate([
|
|
247
|
+
( __param(0, IExtensionService)),
|
|
248
|
+
( __param(1, IConfigurationService)),
|
|
249
|
+
( __param(2, IEnvironmentService)),
|
|
250
|
+
( __param(3, ILogService))
|
|
251
|
+
], WorkbenchLanguageService));
|
|
252
|
+
function isUndefinedOrStringArray(value) {
|
|
253
|
+
if (typeof value === 'undefined') {
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
if (!Array.isArray(value)) {
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
return value.every(item => typeof item === 'string');
|
|
260
|
+
}
|
|
261
|
+
function isValidLanguageExtensionPoint(value, extension, collector) {
|
|
262
|
+
if (!value) {
|
|
263
|
+
collector.error(( localize(
|
|
264
|
+
'invalid.empty',
|
|
265
|
+
"Empty value for `contributes.{0}`",
|
|
266
|
+
languagesExtPoint.name
|
|
267
|
+
)));
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
if (typeof value.id !== 'string') {
|
|
271
|
+
collector.error(( localize(
|
|
272
|
+
'require.id',
|
|
273
|
+
"property `{0}` is mandatory and must be of type `string`",
|
|
274
|
+
'id'
|
|
275
|
+
)));
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
if (!isUndefinedOrStringArray(value.extensions)) {
|
|
279
|
+
collector.error(( localize(
|
|
280
|
+
'opt.extensions',
|
|
281
|
+
"property `{0}` can be omitted and must be of type `string[]`",
|
|
282
|
+
'extensions'
|
|
283
|
+
)));
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
if (!isUndefinedOrStringArray(value.filenames)) {
|
|
287
|
+
collector.error(( localize(
|
|
288
|
+
'opt.filenames',
|
|
289
|
+
"property `{0}` can be omitted and must be of type `string[]`",
|
|
290
|
+
'filenames'
|
|
291
|
+
)));
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
if (typeof value.firstLine !== 'undefined' && typeof value.firstLine !== 'string') {
|
|
295
|
+
collector.error(( localize(
|
|
296
|
+
'opt.firstLine',
|
|
297
|
+
"property `{0}` can be omitted and must be of type `string`",
|
|
298
|
+
'firstLine'
|
|
299
|
+
)));
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
if (typeof value.configuration !== 'undefined' && typeof value.configuration !== 'string') {
|
|
303
|
+
collector.error(( localize(
|
|
304
|
+
'opt.configuration',
|
|
305
|
+
"property `{0}` can be omitted and must be of type `string`",
|
|
306
|
+
'configuration'
|
|
307
|
+
)));
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
if (!isUndefinedOrStringArray(value.aliases)) {
|
|
311
|
+
collector.error(( localize(
|
|
312
|
+
'opt.aliases',
|
|
313
|
+
"property `{0}` can be omitted and must be of type `string[]`",
|
|
314
|
+
'aliases'
|
|
315
|
+
)));
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
if (!isUndefinedOrStringArray(value.mimetypes)) {
|
|
319
|
+
collector.error(( localize(
|
|
320
|
+
'opt.mimetypes',
|
|
321
|
+
"property `{0}` can be omitted and must be of type `string[]`",
|
|
322
|
+
'mimetypes'
|
|
323
|
+
)));
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
if (typeof value.icon !== 'undefined') {
|
|
327
|
+
if (typeof value.icon !== 'object' || typeof value.icon.light !== 'string' || typeof value.icon.dark !== 'string') {
|
|
328
|
+
collector.error(( localize(
|
|
329
|
+
'opt.icon',
|
|
330
|
+
"property `{0}` can be omitted and must be of type `object` with properties `{1}` and `{2}` of type `string`",
|
|
331
|
+
'icon',
|
|
332
|
+
'light',
|
|
333
|
+
'dark'
|
|
334
|
+
)));
|
|
335
|
+
return false;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return true;
|
|
339
|
+
}
|
|
340
|
+
export { WorkbenchLanguageService as W, languagesExtPoint as l };
|