@codingame/monaco-vscode-textmate-service-override 25.1.1 → 26.0.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 (22) hide show
  1. package/_virtual/main2.js +25 -0
  2. package/_virtual/main3.js +3 -0
  3. package/external/vscode-oniguruma/release/main.js +14 -0
  4. package/external/vscode-oniguruma/release/onig.wasm +0 -0
  5. package/index.js +1 -1
  6. package/package.json +3 -5
  7. package/vscode/src/vs/workbench/services/textMate/browser/backgroundTokenization/textMateWorkerTokenizerController.js +42 -26
  8. package/vscode/src/vs/workbench/services/textMate/browser/backgroundTokenization/threadedBackgroundTokenizerFactory.d.ts +1 -1
  9. package/vscode/src/vs/workbench/services/textMate/browser/backgroundTokenization/threadedBackgroundTokenizerFactory.js +32 -24
  10. package/vscode/src/vs/workbench/services/textMate/browser/backgroundTokenization/worker/textMateTokenizationWorker.worker.d.ts +1 -1
  11. package/vscode/src/vs/workbench/services/textMate/browser/backgroundTokenization/worker/textMateTokenizationWorker.worker.js +9 -9
  12. package/vscode/src/vs/workbench/services/textMate/browser/backgroundTokenization/worker/textMateWorkerTokenizer.js +28 -12
  13. package/vscode/src/vs/workbench/services/textMate/browser/textMateTokenizationFeature.contribution.js +14 -8
  14. package/vscode/src/vs/workbench/services/textMate/browser/textMateTokenizationFeatureImpl.d.ts +1 -1
  15. package/vscode/src/vs/workbench/services/textMate/browser/textMateTokenizationFeatureImpl.js +121 -86
  16. package/vscode/src/vs/workbench/services/textMate/browser/tokenizationSupport/textMateTokenizationSupport.d.ts +1 -1
  17. package/vscode/src/vs/workbench/services/textMate/browser/tokenizationSupport/textMateTokenizationSupport.js +14 -5
  18. package/vscode/src/vs/workbench/services/textMate/browser/tokenizationSupport/tokenizationSupportWithLineLimit.js +2 -3
  19. package/vscode/src/vs/workbench/services/textMate/common/TMGrammarFactory.d.ts +2 -2
  20. package/vscode/src/vs/workbench/services/textMate/common/TMGrammarFactory.js +15 -14
  21. package/vscode/src/vs/workbench/services/themes/common/tokenClassificationExtensionPoint.d.ts +0 -3
  22. package/vscode/src/vs/workbench/services/themes/common/tokenClassificationExtensionPoint.js +0 -241
@@ -34,9 +34,27 @@ import { observableFromEvent } from '@codingame/monaco-vscode-api/vscode/vs/base
34
34
 
35
35
  var TextMateTokenizationFeature_1;
36
36
  let TextMateTokenizationFeature = class TextMateTokenizationFeature extends Disposable {
37
- static { TextMateTokenizationFeature_1 = this; }
38
- static { this.reportTokenizationTimeCounter = { sync: 0, async: 0 }; }
39
- constructor(_languageService, _themeService, _extensionResourceLoaderService, _notificationService, _logService, _configurationService, _progressService, _environmentService, _instantiationService, _telemetryService) {
37
+ static {
38
+ TextMateTokenizationFeature_1 = this;
39
+ }
40
+ static {
41
+ this.reportTokenizationTimeCounter = {
42
+ sync: 0,
43
+ async: 0
44
+ };
45
+ }
46
+ constructor(
47
+ _languageService,
48
+ _themeService,
49
+ _extensionResourceLoaderService,
50
+ _notificationService,
51
+ _logService,
52
+ _configurationService,
53
+ _progressService,
54
+ _environmentService,
55
+ _instantiationService,
56
+ _telemetryService
57
+ ) {
40
58
  super();
41
59
  this._languageService = _languageService;
42
60
  this._themeService = _themeService;
@@ -51,31 +69,35 @@ let TextMateTokenizationFeature = class TextMateTokenizationFeature extends Disp
51
69
  this._createdModes = [];
52
70
  this._encounteredLanguages = [];
53
71
  this._debugMode = false;
54
- this._debugModePrintFunc = () => { };
72
+ this._debugModePrintFunc = () => {};
55
73
  this._grammarDefinitions = null;
56
74
  this._grammarFactory = null;
57
75
  this._tokenizersRegistrations = this._register(( new DisposableStore()));
58
76
  this._currentTheme = null;
59
77
  this._currentTokenColorMap = null;
60
78
  this._currentTokenFontMap = null;
61
- this._threadedBackgroundTokenizerFactory = this._instantiationService.createInstance(ThreadedBackgroundTokenizerFactory, (timeMs, languageId, sourceExtensionId, lineLength, isRandomSample) => this._reportTokenizationTime(timeMs, languageId, sourceExtensionId, lineLength, true, isRandomSample), () => this.getAsyncTokenizationEnabled());
79
+ this._threadedBackgroundTokenizerFactory = this._instantiationService.createInstance(
80
+ ThreadedBackgroundTokenizerFactory,
81
+ (timeMs, languageId, sourceExtensionId, lineLength, isRandomSample) => this._reportTokenizationTime(timeMs, languageId, sourceExtensionId, lineLength, true, isRandomSample),
82
+ () => this.getAsyncTokenizationEnabled()
83
+ );
62
84
  this._vscodeOniguruma = null;
63
85
  this._styleElement = createStyleSheet();
64
- this._styleElement.className = 'vscode-tokens-styles';
65
- grammarsExtPoint.setHandler((extensions) => this._handleGrammarsExtPoint(extensions));
86
+ this._styleElement.className = "vscode-tokens-styles";
87
+ grammarsExtPoint.setHandler(extensions => this._handleGrammarsExtPoint(extensions));
66
88
  this._updateTheme(this._themeService.getColorTheme(), true);
67
89
  this._register(this._themeService.onDidColorThemeChange(() => {
68
90
  this._updateTheme(this._themeService.getColorTheme(), false);
69
91
  }));
70
- this._register(this._languageService.onDidRequestRichLanguageFeatures((languageId) => {
92
+ this._register(this._languageService.onDidRequestRichLanguageFeatures(languageId => {
71
93
  this._createdModes.push(languageId);
72
94
  }));
73
95
  }
74
96
  getAsyncTokenizationEnabled() {
75
- return !!this._configurationService.getValue('editor.experimental.asyncTokenization');
97
+ return !!this._configurationService.getValue("editor.experimental.asyncTokenization");
76
98
  }
77
99
  getAsyncTokenizationVerification() {
78
- return !!this._configurationService.getValue('editor.experimental.asyncTokenizationVerification');
100
+ return !!this._configurationService.getValue("editor.experimental.asyncTokenizationVerification");
79
101
  }
80
102
  _handleGrammarsExtPoint(extensions) {
81
103
  this._grammarDefinitions = null;
@@ -94,7 +116,9 @@ let TextMateTokenizationFeature = class TextMateTokenizationFeature extends Disp
94
116
  if (validatedGrammar.language) {
95
117
  const lazyTokenizationSupport = ( new LazyTokenizationSupport(() => this._createTokenizationSupport(validatedGrammar.language)));
96
118
  this._tokenizersRegistrations.add(lazyTokenizationSupport);
97
- this._tokenizersRegistrations.add(TokenizationRegistry.registerFactory(validatedGrammar.language, lazyTokenizationSupport));
119
+ this._tokenizersRegistrations.add(
120
+ TokenizationRegistry.registerFactory(validatedGrammar.language, lazyTokenizationSupport)
121
+ );
98
122
  }
99
123
  }
100
124
  }
@@ -105,7 +129,12 @@ let TextMateTokenizationFeature = class TextMateTokenizationFeature extends Disp
105
129
  }
106
130
  }
107
131
  _validateGrammarDefinition(extension, grammar) {
108
- if (!validateGrammarExtensionPoint(extension.description.extensionLocation, grammar, extension.collector, this._languageService)) {
132
+ if (!validateGrammarExtensionPoint(
133
+ extension.description.extensionLocation,
134
+ grammar,
135
+ extension.collector,
136
+ this._languageService
137
+ )) {
109
138
  return null;
110
139
  }
111
140
  const grammarLocation = joinPath(extension.description.extensionLocation, grammar.path);
@@ -115,7 +144,7 @@ let TextMateTokenizationFeature = class TextMateTokenizationFeature extends Disp
115
144
  for (let i = 0, len = scopes.length; i < len; i++) {
116
145
  const scope = scopes[i];
117
146
  const language = grammar.embeddedLanguages[scope];
118
- if (typeof language !== 'string') {
147
+ if (typeof language !== "string") {
119
148
  continue;
120
149
  }
121
150
  if (this._languageService.isRegisteredLanguageId(language)) {
@@ -129,15 +158,15 @@ let TextMateTokenizationFeature = class TextMateTokenizationFeature extends Disp
129
158
  for (const scope of scopes) {
130
159
  const tokenType = grammar.tokenTypes[scope];
131
160
  switch (tokenType) {
132
- case 'string':
133
- tokenTypes[scope] = StandardTokenType.String;
134
- break;
135
- case 'other':
136
- tokenTypes[scope] = StandardTokenType.Other;
137
- break;
138
- case 'comment':
139
- tokenTypes[scope] = StandardTokenType.Comment;
140
- break;
161
+ case "string":
162
+ tokenTypes[scope] = StandardTokenType.String;
163
+ break;
164
+ case "other":
165
+ tokenTypes[scope] = StandardTokenType.Other;
166
+ break;
167
+ case "comment":
168
+ tokenTypes[scope] = StandardTokenType.Comment;
169
+ break;
141
170
  }
142
171
  }
143
172
  }
@@ -146,7 +175,7 @@ let TextMateTokenizationFeature = class TextMateTokenizationFeature extends Disp
146
175
  if (!Array.isArray(array)) {
147
176
  return defaultValue;
148
177
  }
149
- if (!array.every(e => typeof e === 'string')) {
178
+ if (!array.every(e => typeof e === "string")) {
150
179
  return defaultValue;
151
180
  }
152
181
  return array;
@@ -158,14 +187,14 @@ let TextMateTokenizationFeature = class TextMateTokenizationFeature extends Disp
158
187
  embeddedLanguages: embeddedLanguages,
159
188
  tokenTypes: tokenTypes,
160
189
  injectTo: grammar.injectTo,
161
- balancedBracketSelectors: asStringArray(grammar.balancedBracketScopes, ['*']),
190
+ balancedBracketSelectors: asStringArray(grammar.balancedBracketScopes, ["*"]),
162
191
  unbalancedBracketSelectors: asStringArray(grammar.unbalancedBracketScopes, []),
163
- sourceExtensionId: extension.description.id,
192
+ sourceExtensionId: extension.description.id
164
193
  };
165
194
  }
166
195
  startDebugMode(printFn, onStop) {
167
196
  if (this._debugMode) {
168
- this._notificationService.error(( localize(14277, "Already Logging.")));
197
+ this._notificationService.error(( localize(14669, "Already Logging.")));
169
198
  return;
170
199
  }
171
200
  this._debugModePrintFunc = printFn;
@@ -173,21 +202,21 @@ let TextMateTokenizationFeature = class TextMateTokenizationFeature extends Disp
173
202
  if (this._debugMode) {
174
203
  this._progressService.withProgress({
175
204
  location: ProgressLocation.Notification,
176
- buttons: [( localize(14278, "Stop"))]
177
- }, (progress) => {
205
+ buttons: [( localize(14670, "Stop"))]
206
+ }, progress => {
178
207
  progress.report({
179
- message: ( localize(14279, "Preparing to log TM Grammar parsing. Press Stop when finished."))
208
+ message: ( localize(14671, "Preparing to log TM Grammar parsing. Press Stop when finished."))
180
209
  });
181
- return this._getVSCodeOniguruma().then((vscodeOniguruma) => {
210
+ return this._getVSCodeOniguruma().then(vscodeOniguruma => {
182
211
  vscodeOniguruma.setDefaultDebugCall(true);
183
212
  progress.report({
184
- message: ( localize(14280, "Now logging TM Grammar parsing. Press Stop when finished."))
213
+ message: ( localize(14672, "Now logging TM Grammar parsing. Press Stop when finished."))
185
214
  });
186
- return ( new Promise((resolve, reject) => { }));
215
+ return ( new Promise((resolve, reject) => {}));
187
216
  });
188
- }, (choice) => {
189
- this._getVSCodeOniguruma().then((vscodeOniguruma) => {
190
- this._debugModePrintFunc = () => { };
217
+ }, choice => {
218
+ this._getVSCodeOniguruma().then(vscodeOniguruma => {
219
+ this._debugModePrintFunc = () => {};
191
220
  this._debugMode = false;
192
221
  vscodeOniguruma.setDefaultDebugCall(false);
193
222
  onStop();
@@ -202,18 +231,18 @@ let TextMateTokenizationFeature = class TextMateTokenizationFeature extends Disp
202
231
  if (this._grammarFactory) {
203
232
  return this._grammarFactory;
204
233
  }
205
- const [vscodeTextmate, vscodeOniguruma] = await Promise.all([import('vscode-textmate').then(module => module.default ?? module), this._getVSCodeOniguruma()]);
234
+ const [vscodeTextmate, vscodeOniguruma] = await Promise.all([import('@codingame/monaco-vscode-api/_virtual/main').then(function (n) { return n.main; }), this._getVSCodeOniguruma()]);
206
235
  const onigLib = Promise.resolve({
207
- createOnigScanner: (sources) => vscodeOniguruma.createOnigScanner(sources),
208
- createOnigString: (str) => vscodeOniguruma.createOnigString(str)
236
+ createOnigScanner: sources => vscodeOniguruma.createOnigScanner(sources),
237
+ createOnigString: str => vscodeOniguruma.createOnigString(str)
209
238
  });
210
239
  if (this._grammarFactory) {
211
240
  return this._grammarFactory;
212
241
  }
213
242
  this._grammarFactory = ( new TMGrammarFactory({
214
- logTrace: (msg) => this._logService.trace(msg),
243
+ logTrace: msg => this._logService.trace(msg),
215
244
  logError: (msg, err) => this._logService.error(msg, err),
216
- readFile: (resource) => this._extensionResourceLoaderService.readExtensionResource(resource)
245
+ readFile: resource => this._extensionResourceLoaderService.readExtensionResource(resource)
217
246
  }, this._grammarDefinitions || [], vscodeTextmate, onigLib));
218
247
  this._updateTheme(this._themeService.getColorTheme(), true);
219
248
  return this._grammarFactory;
@@ -235,7 +264,12 @@ let TextMateTokenizationFeature = class TextMateTokenizationFeature extends Disp
235
264
  if (!r.grammar) {
236
265
  return null;
237
266
  }
238
- const maxTokenizationLineLength = observableConfigValue('editor.maxTokenizationLineLength', languageId, -1, this._configurationService);
267
+ const maxTokenizationLineLength = observableConfigValue(
268
+ "editor.maxTokenizationLineLength",
269
+ languageId,
270
+ -1,
271
+ this._configurationService
272
+ );
239
273
  const store = ( new DisposableStore());
240
274
  const tokenization = store.add(( new TextMateTokenizationSupport(
241
275
  r.grammar,
@@ -248,7 +282,7 @@ let TextMateTokenizationFeature = class TextMateTokenizationFeature extends Disp
248
282
  },
249
283
  true
250
284
  )));
251
- store.add(tokenization.onDidEncounterLanguage((encodedLanguageId) => {
285
+ store.add(tokenization.onDidEncounterLanguage(encodedLanguageId => {
252
286
  if (!this._encounteredLanguages[encodedLanguageId]) {
253
287
  const languageId = this._languageService.languageIdCodec.decodeLanguageId(encodedLanguageId);
254
288
  this._encounteredLanguages[encodedLanguageId] = true;
@@ -256,8 +290,7 @@ let TextMateTokenizationFeature = class TextMateTokenizationFeature extends Disp
256
290
  }
257
291
  }));
258
292
  return ( new TokenizationSupportWithLineLimit(encodedLanguageId, tokenization, store, maxTokenizationLineLength));
259
- }
260
- catch (err) {
293
+ } catch (err) {
261
294
  if (err.message && err.message === missingTMGrammarErrorMessage) {
262
295
  return null;
263
296
  }
@@ -266,11 +299,13 @@ let TextMateTokenizationFeature = class TextMateTokenizationFeature extends Disp
266
299
  }
267
300
  }
268
301
  _updateTheme(colorTheme, forceUpdate) {
269
- if (!forceUpdate && this._currentTheme && this._currentTokenColorMap && equalsTokenRules(this._currentTheme.settings, colorTheme.tokenColors)
270
- && equals(this._currentTokenColorMap, colorTheme.tokenColorMap) && this._currentTokenFontMap && equals(this._currentTokenFontMap, colorTheme.tokenFontMap)) {
302
+ if (!forceUpdate && this._currentTheme && this._currentTokenColorMap && equalsTokenRules(this._currentTheme.settings, colorTheme.tokenColors) && equals(this._currentTokenColorMap, colorTheme.tokenColorMap) && this._currentTokenFontMap && equals(this._currentTokenFontMap, colorTheme.tokenFontMap)) {
271
303
  return;
272
304
  }
273
- this._currentTheme = { name: colorTheme.label, settings: colorTheme.tokenColors };
305
+ this._currentTheme = {
306
+ name: colorTheme.label,
307
+ settings: colorTheme.tokenColors
308
+ };
274
309
  this._currentTokenColorMap = colorTheme.tokenColorMap;
275
310
  this._currentTokenFontMap = colorTheme.tokenFontMap;
276
311
  this._grammarFactory?.setTheme(this._currentTheme, this._currentTokenColorMap);
@@ -292,16 +327,18 @@ let TextMateTokenizationFeature = class TextMateTokenizationFeature extends Disp
292
327
  return null;
293
328
  }
294
329
  const encodedLanguageId = this._languageService.languageIdCodec.encodeLanguageId(languageId);
295
- const { grammar } = await grammarFactory.createGrammar(languageId, encodedLanguageId);
330
+ const {
331
+ grammar
332
+ } = await grammarFactory.createGrammar(languageId, encodedLanguageId);
296
333
  return grammar;
297
334
  }
298
335
  _getVSCodeOniguruma() {
299
336
  if (!this._vscodeOniguruma) {
300
337
  this._vscodeOniguruma = (async () => {
301
- const [vscodeOniguruma, wasm] = await Promise.all([import('vscode-oniguruma').then(module => module.default ?? module), this._loadVSCodeOnigurumaWASM()]);
338
+ const [vscodeOniguruma, wasm] = await Promise.all([import('../../../../../../../_virtual/main2.js').then(function (n) { return n.main; }), this._loadVSCodeOnigurumaWASM()]);
302
339
  await vscodeOniguruma.loadWASM({
303
340
  data: wasm,
304
- print: (str) => {
341
+ print: str => {
305
342
  this._debugModePrintFunc(str);
306
343
  }
307
344
  });
@@ -312,16 +349,22 @@ let TextMateTokenizationFeature = class TextMateTokenizationFeature extends Disp
312
349
  }
313
350
  async _loadVSCodeOnigurumaWASM() {
314
351
  if (isWeb) {
315
- const response = await fetch(( new URL('vscode-oniguruma/release/onig.wasm', import.meta.url)).href);
352
+ const response = await fetch(( new URL('../../../../../../../external/vscode-oniguruma/release/onig.wasm', import.meta.url)).href);
316
353
  return await response.arrayBuffer();
317
- }
318
- else {
354
+ } else {
319
355
  const response = await fetch(( ( FileAccess.asBrowserUri(`${nodeModulesPath}/vscode-oniguruma/release/onig.wasm`)).toString(true)));
320
356
  return response;
321
357
  }
322
358
  }
323
- _reportTokenizationTime(timeMs, languageId, sourceExtensionId, lineLength, fromWorker, isRandomSample) {
324
- const key = fromWorker ? 'async' : 'sync';
359
+ _reportTokenizationTime(
360
+ timeMs,
361
+ languageId,
362
+ sourceExtensionId,
363
+ lineLength,
364
+ fromWorker,
365
+ isRandomSample
366
+ ) {
367
+ const key = fromWorker ? "async" : "sync";
325
368
  if (TextMateTokenizationFeature_1.reportTokenizationTimeCounter[key] > 50) {
326
369
  return;
327
370
  }
@@ -331,29 +374,18 @@ let TextMateTokenizationFeature = class TextMateTokenizationFeature extends Disp
331
374
  }, 1000 * 60 * 60);
332
375
  }
333
376
  TextMateTokenizationFeature_1.reportTokenizationTimeCounter[key]++;
334
- this._telemetryService.publicLog2('editor.tokenizedLine', {
377
+ this._telemetryService.publicLog2("editor.tokenizedLine", {
335
378
  timeMs,
336
379
  languageId,
337
380
  lineLength,
338
381
  fromWorker,
339
382
  sourceExtensionId,
340
383
  isRandomSample,
341
- tokenizationSetting: this.getAsyncTokenizationEnabled() ? (this.getAsyncTokenizationVerification() ? 2 : 1) : 0,
384
+ tokenizationSetting: this.getAsyncTokenizationEnabled() ? (this.getAsyncTokenizationVerification() ? 2 : 1) : 0
342
385
  });
343
386
  }
344
387
  };
345
- TextMateTokenizationFeature = TextMateTokenizationFeature_1 = ( __decorate([
346
- ( __param(0, ILanguageService)),
347
- ( __param(1, IWorkbenchThemeService)),
348
- ( __param(2, IExtensionResourceLoaderService)),
349
- ( __param(3, INotificationService)),
350
- ( __param(4, ILogService)),
351
- ( __param(5, IConfigurationService)),
352
- ( __param(6, IProgressService)),
353
- ( __param(7, IWorkbenchEnvironmentService)),
354
- ( __param(8, IInstantiationService)),
355
- ( __param(9, ITelemetryService))
356
- ], TextMateTokenizationFeature));
388
+ TextMateTokenizationFeature = TextMateTokenizationFeature_1 = ( __decorate([( __param(0, ILanguageService)), ( __param(1, IWorkbenchThemeService)), ( __param(2, IExtensionResourceLoaderService)), ( __param(3, INotificationService)), ( __param(4, ILogService)), ( __param(5, IConfigurationService)), ( __param(6, IProgressService)), ( __param(7, IWorkbenchEnvironmentService)), ( __param(8, IInstantiationService)), ( __param(9, ITelemetryService))], TextMateTokenizationFeature));
357
389
  function toColorMap(colorMap) {
358
390
  const result = [null];
359
391
  for (let i = 1, len = colorMap.length; i < len; i++) {
@@ -374,47 +406,46 @@ function equalsTokenRules(a, b) {
374
406
  const s1 = r1.settings;
375
407
  const s2 = r2.settings;
376
408
  if (s1 && s2) {
377
- if (s1.fontStyle !== s2.fontStyle || s1.foreground !== s2.foreground || s1.background !== s2.background) {
409
+ if (s1.fontStyle !== s2.fontStyle || s1.foreground !== s2.foreground || s1.background !== s2.background || s1.lineHeight !== s2.lineHeight || s1.fontSize !== s2.fontSize || s1.fontFamily !== s2.fontFamily) {
378
410
  return false;
379
411
  }
380
- }
381
- else if (!s1 || !s2) {
412
+ } else if (!s1 || !s2) {
382
413
  return false;
383
414
  }
384
415
  }
385
416
  return true;
386
417
  }
387
418
  function validateGrammarExtensionPoint(extensionLocation, syntax, collector, _languageService) {
388
- if (syntax.language && ((typeof syntax.language !== 'string') || !_languageService.isRegisteredLanguageId(syntax.language))) {
419
+ if (syntax.language && ((typeof syntax.language !== "string") || !_languageService.isRegisteredLanguageId(syntax.language))) {
389
420
  collector.error(( localize(
390
- 14281,
421
+ 14673,
391
422
  "Unknown language in `contributes.{0}.language`. Provided value: {1}",
392
423
  grammarsExtPoint.name,
393
424
  String(syntax.language)
394
425
  )));
395
426
  return false;
396
427
  }
397
- if (!syntax.scopeName || (typeof syntax.scopeName !== 'string')) {
428
+ if (!syntax.scopeName || (typeof syntax.scopeName !== "string")) {
398
429
  collector.error(( localize(
399
- 14282,
430
+ 14674,
400
431
  "Expected string in `contributes.{0}.scopeName`. Provided value: {1}",
401
432
  grammarsExtPoint.name,
402
433
  String(syntax.scopeName)
403
434
  )));
404
435
  return false;
405
436
  }
406
- if (!syntax.path || (typeof syntax.path !== 'string')) {
437
+ if (!syntax.path || (typeof syntax.path !== "string")) {
407
438
  collector.error(( localize(
408
- 14283,
439
+ 14675,
409
440
  "Expected string in `contributes.{0}.path`. Provided value: {1}",
410
441
  grammarsExtPoint.name,
411
442
  String(syntax.path)
412
443
  )));
413
444
  return false;
414
445
  }
415
- if (syntax.injectTo && (!Array.isArray(syntax.injectTo) || ( syntax.injectTo.some(scope => typeof scope !== 'string')))) {
446
+ if (syntax.injectTo && (!Array.isArray(syntax.injectTo) || ( syntax.injectTo.some(scope => typeof scope !== "string")))) {
416
447
  collector.error(( localize(
417
- 14284,
448
+ 14676,
418
449
  "Invalid value in `contributes.{0}.injectTo`. Must be an array of language scope names. Provided value: {1}",
419
450
  grammarsExtPoint.name,
420
451
  JSON.stringify(syntax.injectTo)
@@ -423,7 +454,7 @@ function validateGrammarExtensionPoint(extensionLocation, syntax, collector, _la
423
454
  }
424
455
  if (syntax.embeddedLanguages && !isObject(syntax.embeddedLanguages)) {
425
456
  collector.error(( localize(
426
- 14285,
457
+ 14677,
427
458
  "Invalid value in `contributes.{0}.embeddedLanguages`. Must be an object map from scope name to language. Provided value: {1}",
428
459
  grammarsExtPoint.name,
429
460
  JSON.stringify(syntax.embeddedLanguages)
@@ -432,7 +463,7 @@ function validateGrammarExtensionPoint(extensionLocation, syntax, collector, _la
432
463
  }
433
464
  if (syntax.tokenTypes && !isObject(syntax.tokenTypes)) {
434
465
  collector.error(( localize(
435
- 14286,
466
+ 14678,
436
467
  "Invalid value in `contributes.{0}.tokenTypes`. Must be an object map from scope name to token type. Provided value: {1}",
437
468
  grammarsExtPoint.name,
438
469
  JSON.stringify(syntax.tokenTypes)
@@ -442,7 +473,7 @@ function validateGrammarExtensionPoint(extensionLocation, syntax, collector, _la
442
473
  const grammarLocation = joinPath(extensionLocation, syntax.path);
443
474
  if (!isEqualOrParent(grammarLocation, extensionLocation)) {
444
475
  collector.warn(( localize(
445
- 14287,
476
+ 14679,
446
477
  "Expected `contributes.{0}.path` ({1}) to be included inside extension's folder ({2}). This might make the extension non-portable.",
447
478
  grammarsExtPoint.name,
448
479
  grammarLocation.path,
@@ -452,11 +483,15 @@ function validateGrammarExtensionPoint(extensionLocation, syntax, collector, _la
452
483
  return true;
453
484
  }
454
485
  function observableConfigValue(key, languageId, defaultValue, configurationService) {
455
- return observableFromEvent((handleChange) => configurationService.onDidChangeConfiguration(e => {
456
- if (e.affectsConfiguration(key, { overrideIdentifier: languageId })) {
486
+ return observableFromEvent(handleChange => configurationService.onDidChangeConfiguration(e => {
487
+ if (e.affectsConfiguration(key, {
488
+ overrideIdentifier: languageId
489
+ })) {
457
490
  handleChange(e);
458
491
  }
459
- }), () => configurationService.getValue(key, { overrideIdentifier: languageId }) ?? defaultValue);
492
+ }), () => configurationService.getValue(key, {
493
+ overrideIdentifier: languageId
494
+ }) ?? defaultValue);
460
495
  }
461
496
 
462
497
  export { TextMateTokenizationFeature };
@@ -3,7 +3,7 @@ import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/l
3
3
  import { LanguageId } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/encodedTokenAttributes";
4
4
  import { EncodedTokenizationResult, IBackgroundTokenizationStore, IBackgroundTokenizer, IState, ITokenizationSupport, TokenizationResult } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/languages";
5
5
  import { ITextModel } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/model";
6
- import type { IGrammar, StateStack } from "vscode-textmate";
6
+ import type { IGrammar, StateStack } from "@codingame/monaco-vscode-api/_virtual/main";
7
7
  export declare class TextMateTokenizationSupport extends Disposable implements ITokenizationSupport {
8
8
  private readonly _grammar;
9
9
  private readonly _initialState;
@@ -6,8 +6,18 @@ import { TokenMetadata } from '@codingame/monaco-vscode-api/vscode/vs/editor/com
6
6
  import { EncodedTokenizationResult } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/languages';
7
7
 
8
8
  class TextMateTokenizationSupport extends Disposable {
9
- get onDidEncounterLanguage() { return this._onDidEncounterLanguage.event; }
10
- constructor(_grammar, _initialState, _containsEmbeddedLanguages, _createBackgroundTokenizer, _backgroundTokenizerShouldOnlyVerifyTokens, _reportTokenizationTime, _reportSlowTokenization) {
9
+ get onDidEncounterLanguage() {
10
+ return this._onDidEncounterLanguage.event;
11
+ }
12
+ constructor(
13
+ _grammar,
14
+ _initialState,
15
+ _containsEmbeddedLanguages,
16
+ _createBackgroundTokenizer,
17
+ _backgroundTokenizerShouldOnlyVerifyTokens,
18
+ _reportTokenizationTime,
19
+ _reportSlowTokenization
20
+ ) {
11
21
  super();
12
22
  this._grammar = _grammar;
13
23
  this._initialState = _initialState;
@@ -26,7 +36,7 @@ class TextMateTokenizationSupport extends Disposable {
26
36
  return this._initialState;
27
37
  }
28
38
  tokenize(line, hasEOL, state) {
29
- throw ( new Error('Not supported!'));
39
+ throw ( new Error("Not supported!"));
30
40
  }
31
41
  createBackgroundTokenizer(textModel, store) {
32
42
  if (this._createBackgroundTokenizer) {
@@ -64,8 +74,7 @@ class TextMateTokenizationSupport extends Disposable {
64
74
  let endState;
65
75
  if (state.equals(textMateResult.ruleStack)) {
66
76
  endState = state;
67
- }
68
- else {
77
+ } else {
69
78
  endState = textMateResult.ruleStack;
70
79
  }
71
80
  return ( new EncodedTokenizationResult(textMateResult.tokens, textMateResult.fonts, endState));
@@ -20,7 +20,7 @@ class TokenizationSupportWithLineLimit extends Disposable {
20
20
  return this._actual.getInitialState();
21
21
  }
22
22
  tokenize(line, hasEOL, state) {
23
- throw ( new Error('Not supported!'));
23
+ throw ( new Error("Not supported!"));
24
24
  }
25
25
  tokenizeEncoded(line, hasEOL, state) {
26
26
  if (line.length >= this._maxTokenizationLineLength.get()) {
@@ -31,8 +31,7 @@ class TokenizationSupportWithLineLimit extends Disposable {
31
31
  createBackgroundTokenizer(textModel, store) {
32
32
  if (this._actual.createBackgroundTokenizer) {
33
33
  return this._actual.createBackgroundTokenizer(textModel, store);
34
- }
35
- else {
34
+ } else {
36
35
  return undefined;
37
36
  }
38
37
  }
@@ -1,7 +1,7 @@
1
1
  import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
2
2
  import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
3
3
  import { IValidGrammarDefinition } from "./TMScopeRegistry.js";
4
- import type { IGrammar, IOnigLib, IRawTheme, StateStack } from "vscode-textmate";
4
+ import type { IGrammar, IOnigLib, IRawTheme, StateStack } from "@codingame/monaco-vscode-api/_virtual/main";
5
5
  interface ITMGrammarFactoryHost {
6
6
  logTrace(msg: string): void;
7
7
  logError(msg: string, err: any): void;
@@ -23,7 +23,7 @@ export declare class TMGrammarFactory extends Disposable {
23
23
  private readonly _injectedEmbeddedLanguages;
24
24
  private readonly _languageToScope;
25
25
  private readonly _grammarRegistry;
26
- constructor(host: ITMGrammarFactoryHost, grammarDefinitions: IValidGrammarDefinition[], vscodeTextmate: typeof import("vscode-textmate"), onigLib: Promise<IOnigLib>);
26
+ constructor(host: ITMGrammarFactoryHost, grammarDefinitions: IValidGrammarDefinition[], vscodeTextmate: typeof import("@codingame/monaco-vscode-api/_virtual/main"), onigLib: Promise<IOnigLib>);
27
27
  has(languageId: string): boolean;
28
28
  setTheme(theme: IRawTheme, colorMap: string[]): void;
29
29
  getColorMap(): string[];
@@ -2,7 +2,7 @@
2
2
  import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
3
3
  import { TMScopeRegistry } from './TMScopeRegistry.js';
4
4
 
5
- const missingTMGrammarErrorMessage = 'No TM Grammar registered for this language.';
5
+ const missingTMGrammarErrorMessage = "No TM Grammar registered for this language.";
6
6
  class TMGrammarFactory extends Disposable {
7
7
  constructor(host, grammarDefinitions, vscodeTextmate, onigLib) {
8
8
  super();
@@ -14,7 +14,7 @@ class TMGrammarFactory extends Disposable {
14
14
  this._languageToScope = ( new Map());
15
15
  this._grammarRegistry = this._register(new vscodeTextmate.Registry({
16
16
  onigLib: onigLib,
17
- loadGrammar: async (scopeName) => {
17
+ loadGrammar: async scopeName => {
18
18
  const grammarDefinition = this._scopeRegistry.getGrammarDefinition(scopeName);
19
19
  if (!grammarDefinition) {
20
20
  this._host.logTrace(`No grammar found for scope ${scopeName}`);
@@ -24,17 +24,19 @@ class TMGrammarFactory extends Disposable {
24
24
  try {
25
25
  const content = await this._host.readFile(location);
26
26
  return vscodeTextmate.parseRawGrammar(content, location.path);
27
- }
28
- catch (e) {
29
- this._host.logError(`Unable to load and parse grammar for scope ${scopeName} from ${location}`, e);
27
+ } catch (e) {
28
+ this._host.logError(
29
+ `Unable to load and parse grammar for scope ${scopeName} from ${location}`,
30
+ e
31
+ );
30
32
  return null;
31
33
  }
32
34
  },
33
- getInjections: (scopeName) => {
34
- const scopeParts = scopeName.split('.');
35
+ getInjections: scopeName => {
36
+ const scopeParts = scopeName.split(".");
35
37
  let injections = [];
36
38
  for (let i = 1; i <= scopeParts.length; i++) {
37
- const subScopeName = scopeParts.slice(0, i).join('.');
39
+ const subScopeName = scopeParts.slice(0, i).join(".");
38
40
  injections = [...injections, ...(this._injections[subScopeName] || [])];
39
41
  }
40
42
  return injections;
@@ -76,7 +78,7 @@ class TMGrammarFactory extends Disposable {
76
78
  }
77
79
  async createGrammar(languageId, encodedLanguageId) {
78
80
  const scopeName = this._languageToScope.get(languageId);
79
- if (typeof scopeName !== 'string') {
81
+ if (typeof scopeName !== "string") {
80
82
  throw ( new Error(missingTMGrammarErrorMessage));
81
83
  }
82
84
  const grammarDefinition = this._scopeRegistry.getGrammarDefinition(scopeName);
@@ -99,11 +101,10 @@ class TMGrammarFactory extends Disposable {
99
101
  embeddedLanguages,
100
102
  tokenTypes: grammarDefinition.tokenTypes,
101
103
  balancedBracketSelectors: grammarDefinition.balancedBracketSelectors,
102
- unbalancedBracketSelectors: grammarDefinition.unbalancedBracketSelectors,
104
+ unbalancedBracketSelectors: grammarDefinition.unbalancedBracketSelectors
103
105
  });
104
- }
105
- catch (err) {
106
- if (err.message && err.message.startsWith('No grammar provided for')) {
106
+ } catch (err) {
107
+ if (err.message && err.message.startsWith("No grammar provided for")) {
107
108
  throw ( new Error(missingTMGrammarErrorMessage));
108
109
  }
109
110
  throw err;
@@ -113,7 +114,7 @@ class TMGrammarFactory extends Disposable {
113
114
  grammar: grammar,
114
115
  initialState: this._initialState,
115
116
  containsEmbeddedLanguages: containsEmbeddedLanguages,
116
- sourceExtensionId: grammarDefinition.sourceExtensionId,
117
+ sourceExtensionId: grammarDefinition.sourceExtensionId
117
118
  };
118
119
  }
119
120
  }
@@ -1,3 +0,0 @@
1
- export declare class TokenClassificationExtensionPoints {
2
- constructor();
3
- }