@codingame/monaco-vscode-textmate-service-override 17.2.1 → 18.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.
- package/package.json +6 -6
- package/vscode/src/vs/workbench/services/textMate/browser/backgroundTokenization/textMateWorkerTokenizerController.js +7 -14
- package/vscode/src/vs/workbench/services/textMate/browser/backgroundTokenization/worker/textMateWorkerTokenizer.js +2 -2
- package/vscode/src/vs/workbench/services/textMate/browser/{arrayOperation.d.ts → indexTransformer.d.ts} +3 -14
- package/vscode/src/vs/workbench/services/textMate/browser/indexTransformer.js +42 -0
- package/vscode/src/vs/workbench/services/textMate/browser/textMateTokenizationFeatureImpl.d.ts +1 -1
- package/vscode/src/vs/workbench/services/textMate/browser/textMateTokenizationFeatureImpl.js +13 -13
- package/vscode/src/vs/workbench/services/textMate/browser/tokenizationSupport/tokenizationSupportWithLineLimit.js +1 -1
- package/vscode/src/vs/workbench/services/themes/common/tokenClassificationExtensionPoint.js +25 -25
- package/vscode/src/vs/workbench/services/textMate/browser/arrayOperation.js +0 -65
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-textmate-service-override",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "18.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "VSCode public API plugged on the monaco editor - textmate service-override",
|
|
6
6
|
"keywords": [],
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@codingame/monaco-vscode-1ba786a5-b7d7-5d26-8a85-ae48ee2a74a4-common": "
|
|
19
|
-
"@codingame/monaco-vscode-33833ac7-3af3-5e9d-8fb9-11838d852c59-common": "
|
|
20
|
-
"@codingame/monaco-vscode-
|
|
21
|
-
"@codingame/monaco-vscode-api": "
|
|
22
|
-
"@codingame/monaco-vscode-files-service-override": "
|
|
18
|
+
"@codingame/monaco-vscode-1ba786a5-b7d7-5d26-8a85-ae48ee2a74a4-common": "18.0.0",
|
|
19
|
+
"@codingame/monaco-vscode-33833ac7-3af3-5e9d-8fb9-11838d852c59-common": "18.0.0",
|
|
20
|
+
"@codingame/monaco-vscode-93784a59-b4cf-520c-8339-f8104d3a4f3e-common": "18.0.0",
|
|
21
|
+
"@codingame/monaco-vscode-api": "18.0.0",
|
|
22
|
+
"@codingame/monaco-vscode-files-service-override": "18.0.0",
|
|
23
23
|
"vscode-oniguruma": "1.7.0",
|
|
24
24
|
"vscode-textmate": "9.2.0"
|
|
25
25
|
},
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
|
|
2
2
|
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
3
3
|
import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
|
|
4
|
-
import {
|
|
5
|
-
import { LineRange } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/lineRange';
|
|
4
|
+
import { LineRange } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/ranges/lineRange';
|
|
6
5
|
import { Range } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/range';
|
|
7
6
|
import { TokenizationStateStore } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/model/textModelTokens';
|
|
8
7
|
import { ContiguousMultilineTokensBuilder } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/tokens/contiguousMultilineTokensBuilder';
|
|
9
8
|
import { observableConfigValue } from '@codingame/monaco-vscode-api/vscode/vs/platform/observable/common/platformObservableUtils';
|
|
10
|
-
import { MonotonousIndexTransformer
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
9
|
+
import { MonotonousIndexTransformer } from '../indexTransformer.js';
|
|
10
|
+
import { linesLengthEditFromModelContentChange } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/model/textModelStringEdit';
|
|
11
|
+
import { keepObserved } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/utils/utils';
|
|
12
|
+
import { autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/reactions/autorun';
|
|
13
13
|
|
|
14
14
|
class TextMateWorkerTokenizerController extends Disposable {
|
|
15
15
|
static { this._id = 0; }
|
|
@@ -91,7 +91,7 @@ class TextMateWorkerTokenizerController extends Disposable {
|
|
|
91
91
|
const changes = ( ( this._pendingChanges.map(c => c.changes)).map(c => changesToString(c))).join(' then ');
|
|
92
92
|
console.log('Considering non-processed changes', changes);
|
|
93
93
|
}
|
|
94
|
-
const curToFutureTransformerTokens = MonotonousIndexTransformer.fromMany(( this._pendingChanges.map((c) =>
|
|
94
|
+
const curToFutureTransformerTokens = MonotonousIndexTransformer.fromMany(( this._pendingChanges.map((c) => linesLengthEditFromModelContentChange(c.changes))));
|
|
95
95
|
const b = ( new ContiguousMultilineTokensBuilder());
|
|
96
96
|
for (const t of tokens) {
|
|
97
97
|
for (let i = t.startLineNumber; i <= t.endLineNumber; i++) {
|
|
@@ -110,7 +110,7 @@ class TextMateWorkerTokenizerController extends Disposable {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
-
const curToFutureTransformerStates = MonotonousIndexTransformer.fromMany(( this._pendingChanges.map((c) =>
|
|
113
|
+
const curToFutureTransformerStates = MonotonousIndexTransformer.fromMany(( this._pendingChanges.map((c) => linesLengthEditFromModelContentChange(c.changes))));
|
|
114
114
|
if (!this._applyStateStackDiffFn || !this._initialState) {
|
|
115
115
|
const { applyStateStackDiff, INITIAL } = await import('vscode-textmate').then(module => module.default ?? module);
|
|
116
116
|
this._applyStateStackDiffFn = applyStateStackDiff;
|
|
@@ -142,13 +142,6 @@ class TextMateWorkerTokenizerController extends Disposable {
|
|
|
142
142
|
}
|
|
143
143
|
get _shouldLog() { return this._loggingEnabled.get(); }
|
|
144
144
|
}
|
|
145
|
-
function fullLineArrayEditFromModelContentChange(c) {
|
|
146
|
-
return ( new ArrayEdit(( c.map((c) => ( new SingleArrayEdit(
|
|
147
|
-
c.range.startLineNumber - 1,
|
|
148
|
-
c.range.endLineNumber - c.range.startLineNumber + 1,
|
|
149
|
-
countEOL(c.text)[0] + 1
|
|
150
|
-
))))));
|
|
151
|
-
}
|
|
152
145
|
function changesToString(changes) {
|
|
153
146
|
return ( changes.map(c => ( Range.lift(c.range).toString()) + ' => ' + c.text)).join(' & ');
|
|
154
147
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { RunOnceScheduler } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
|
|
3
3
|
import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
|
|
4
4
|
import { setTimeout0 } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
|
|
5
|
-
import { LineRange } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/lineRange';
|
|
5
|
+
import { LineRange } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/ranges/lineRange';
|
|
6
6
|
import { MirrorTextModel } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/model/mirrorTextModel';
|
|
7
7
|
import { TokenizerWithStateStore } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/model/textModelTokens';
|
|
8
8
|
import { ContiguousMultilineTokensBuilder } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/tokens/contiguousMultilineTokensBuilder';
|
|
@@ -10,7 +10,7 @@ import { LineTokens } from '@codingame/monaco-vscode-api/vscode/vs/editor/common
|
|
|
10
10
|
import { TextMateTokenizationSupport } from '../../tokenizationSupport/textMateTokenizationSupport.js';
|
|
11
11
|
import { TokenizationSupportWithLineLimit } from '../../tokenizationSupport/tokenizationSupportWithLineLimit.js';
|
|
12
12
|
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
13
|
-
import { observableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/
|
|
13
|
+
import { observableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableValue';
|
|
14
14
|
|
|
15
15
|
class TextMateWorkerTokenizer extends MirrorTextModel {
|
|
16
16
|
constructor(uri, lines, eol, versionId, _host, _languageId, _encodedLanguageId, maxTokenizationLineLength) {
|
|
@@ -1,24 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
readonly edits: readonly SingleArrayEdit[];
|
|
3
|
-
constructor(edits: readonly SingleArrayEdit[]);
|
|
4
|
-
applyToArray(array: any[]): void;
|
|
5
|
-
}
|
|
6
|
-
export declare class SingleArrayEdit {
|
|
7
|
-
readonly offset: number;
|
|
8
|
-
readonly length: number;
|
|
9
|
-
readonly newLength: number;
|
|
10
|
-
constructor(offset: number, length: number, newLength: number);
|
|
11
|
-
toString(): string;
|
|
12
|
-
}
|
|
1
|
+
import { AnyEdit } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/core/edits/edit";
|
|
13
2
|
export interface IIndexTransformer {
|
|
14
3
|
transform(index: number): number | undefined;
|
|
15
4
|
}
|
|
16
5
|
export declare class MonotonousIndexTransformer implements IIndexTransformer {
|
|
17
6
|
private readonly transformation;
|
|
18
|
-
static fromMany(transformations:
|
|
7
|
+
static fromMany(transformations: AnyEdit[]): IIndexTransformer;
|
|
19
8
|
private idx;
|
|
20
9
|
private offset;
|
|
21
|
-
constructor(transformation:
|
|
10
|
+
constructor(transformation: AnyEdit);
|
|
22
11
|
transform(index: number): number | undefined;
|
|
23
12
|
}
|
|
24
13
|
export declare class CombinedIndexTransformer implements IIndexTransformer {
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
class MonotonousIndexTransformer {
|
|
4
|
+
static fromMany(transformations) {
|
|
5
|
+
const transformers = ( transformations.map(t => ( new MonotonousIndexTransformer(t))));
|
|
6
|
+
return ( new CombinedIndexTransformer(transformers));
|
|
7
|
+
}
|
|
8
|
+
constructor(transformation) {
|
|
9
|
+
this.transformation = transformation;
|
|
10
|
+
this.idx = 0;
|
|
11
|
+
this.offset = 0;
|
|
12
|
+
}
|
|
13
|
+
transform(index) {
|
|
14
|
+
let nextChange = this.transformation.replacements.at(this.idx);
|
|
15
|
+
while (nextChange && nextChange.replaceRange.endExclusive <= index) {
|
|
16
|
+
this.offset += nextChange.getLengthDelta();
|
|
17
|
+
this.idx++;
|
|
18
|
+
nextChange = this.transformation.replacements.at(this.idx);
|
|
19
|
+
}
|
|
20
|
+
if (nextChange && nextChange.replaceRange.start <= index) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
return index + this.offset;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
class CombinedIndexTransformer {
|
|
27
|
+
constructor(transformers) {
|
|
28
|
+
this.transformers = transformers;
|
|
29
|
+
}
|
|
30
|
+
transform(index) {
|
|
31
|
+
for (const transformer of this.transformers) {
|
|
32
|
+
const result = transformer.transform(index);
|
|
33
|
+
if (result === undefined) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
index = result;
|
|
37
|
+
}
|
|
38
|
+
return index;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { CombinedIndexTransformer, MonotonousIndexTransformer };
|
package/vscode/src/vs/workbench/services/textMate/browser/textMateTokenizationFeatureImpl.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { IProgressService } from "@codingame/monaco-vscode-api/vscode/vs/platfor
|
|
|
9
9
|
import { ITelemetryService } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service";
|
|
10
10
|
import { IWorkbenchEnvironmentService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/environment/common/environmentService.service";
|
|
11
11
|
import { ITextMateTokenizationService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/textMate/browser/textMateTokenizationFeature.service";
|
|
12
|
-
import { IWorkbenchThemeService } from "@codingame/monaco-vscode-
|
|
12
|
+
import { IWorkbenchThemeService } from "@codingame/monaco-vscode-93784a59-b4cf-520c-8339-f8104d3a4f3e-common/vscode/vs/workbench/services/themes/common/workbenchThemeService.service";
|
|
13
13
|
import type { IGrammar } from "vscode-textmate";
|
|
14
14
|
export declare class TextMateTokenizationFeature extends Disposable implements ITextMateTokenizationService {
|
|
15
15
|
private readonly _languageService;
|
package/vscode/src/vs/workbench/services/textMate/browser/textMateTokenizationFeatureImpl.js
CHANGED
|
@@ -29,8 +29,8 @@ import { TokenizationSupportWithLineLimit } from './tokenizationSupport/tokeniza
|
|
|
29
29
|
import { ThreadedBackgroundTokenizerFactory } from './backgroundTokenization/threadedBackgroundTokenizerFactory.js';
|
|
30
30
|
import { TMGrammarFactory, missingTMGrammarErrorMessage } from '../common/TMGrammarFactory.js';
|
|
31
31
|
import { grammarsExtPoint } from '@codingame/monaco-vscode-33833ac7-3af3-5e9d-8fb9-11838d852c59-common/vscode/vs/workbench/services/textMate/common/TMGrammars';
|
|
32
|
-
import { IWorkbenchThemeService } from '@codingame/monaco-vscode-
|
|
33
|
-
import { observableFromEvent } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/
|
|
32
|
+
import { IWorkbenchThemeService } from '@codingame/monaco-vscode-93784a59-b4cf-520c-8339-f8104d3a4f3e-common/vscode/vs/workbench/services/themes/common/workbenchThemeService.service';
|
|
33
|
+
import { observableFromEvent } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableFromEvent';
|
|
34
34
|
|
|
35
35
|
var TextMateTokenizationFeature_1;
|
|
36
36
|
let TextMateTokenizationFeature = class TextMateTokenizationFeature extends Disposable {
|
|
@@ -164,7 +164,7 @@ let TextMateTokenizationFeature = class TextMateTokenizationFeature extends Disp
|
|
|
164
164
|
}
|
|
165
165
|
startDebugMode(printFn, onStop) {
|
|
166
166
|
if (this._debugMode) {
|
|
167
|
-
this._notificationService.error(( localize(
|
|
167
|
+
this._notificationService.error(( localize(12852, "Already Logging.")));
|
|
168
168
|
return;
|
|
169
169
|
}
|
|
170
170
|
this._debugModePrintFunc = printFn;
|
|
@@ -172,15 +172,15 @@ let TextMateTokenizationFeature = class TextMateTokenizationFeature extends Disp
|
|
|
172
172
|
if (this._debugMode) {
|
|
173
173
|
this._progressService.withProgress({
|
|
174
174
|
location: ProgressLocation.Notification,
|
|
175
|
-
buttons: [( localize(
|
|
175
|
+
buttons: [( localize(12853, "Stop"))]
|
|
176
176
|
}, (progress) => {
|
|
177
177
|
progress.report({
|
|
178
|
-
message: ( localize(
|
|
178
|
+
message: ( localize(12854, "Preparing to log TM Grammar parsing. Press Stop when finished."))
|
|
179
179
|
});
|
|
180
180
|
return this._getVSCodeOniguruma().then((vscodeOniguruma) => {
|
|
181
181
|
vscodeOniguruma.setDefaultDebugCall(true);
|
|
182
182
|
progress.report({
|
|
183
|
-
message: ( localize(
|
|
183
|
+
message: ( localize(12855, "Now logging TM Grammar parsing. Press Stop when finished."))
|
|
184
184
|
});
|
|
185
185
|
return ( new Promise((resolve, reject) => { }));
|
|
186
186
|
});
|
|
@@ -384,7 +384,7 @@ function equalsTokenRules(a, b) {
|
|
|
384
384
|
function validateGrammarExtensionPoint(extensionLocation, syntax, collector, _languageService) {
|
|
385
385
|
if (syntax.language && ((typeof syntax.language !== 'string') || !_languageService.isRegisteredLanguageId(syntax.language))) {
|
|
386
386
|
collector.error(( localize(
|
|
387
|
-
|
|
387
|
+
12856,
|
|
388
388
|
"Unknown language in `contributes.{0}.language`. Provided value: {1}",
|
|
389
389
|
grammarsExtPoint.name,
|
|
390
390
|
String(syntax.language)
|
|
@@ -393,7 +393,7 @@ function validateGrammarExtensionPoint(extensionLocation, syntax, collector, _la
|
|
|
393
393
|
}
|
|
394
394
|
if (!syntax.scopeName || (typeof syntax.scopeName !== 'string')) {
|
|
395
395
|
collector.error(( localize(
|
|
396
|
-
|
|
396
|
+
12857,
|
|
397
397
|
"Expected string in `contributes.{0}.scopeName`. Provided value: {1}",
|
|
398
398
|
grammarsExtPoint.name,
|
|
399
399
|
String(syntax.scopeName)
|
|
@@ -402,7 +402,7 @@ function validateGrammarExtensionPoint(extensionLocation, syntax, collector, _la
|
|
|
402
402
|
}
|
|
403
403
|
if (!syntax.path || (typeof syntax.path !== 'string')) {
|
|
404
404
|
collector.error(( localize(
|
|
405
|
-
|
|
405
|
+
12858,
|
|
406
406
|
"Expected string in `contributes.{0}.path`. Provided value: {1}",
|
|
407
407
|
grammarsExtPoint.name,
|
|
408
408
|
String(syntax.path)
|
|
@@ -411,7 +411,7 @@ function validateGrammarExtensionPoint(extensionLocation, syntax, collector, _la
|
|
|
411
411
|
}
|
|
412
412
|
if (syntax.injectTo && (!Array.isArray(syntax.injectTo) || ( syntax.injectTo.some(scope => typeof scope !== 'string')))) {
|
|
413
413
|
collector.error(( localize(
|
|
414
|
-
|
|
414
|
+
12859,
|
|
415
415
|
"Invalid value in `contributes.{0}.injectTo`. Must be an array of language scope names. Provided value: {1}",
|
|
416
416
|
grammarsExtPoint.name,
|
|
417
417
|
JSON.stringify(syntax.injectTo)
|
|
@@ -420,7 +420,7 @@ function validateGrammarExtensionPoint(extensionLocation, syntax, collector, _la
|
|
|
420
420
|
}
|
|
421
421
|
if (syntax.embeddedLanguages && !isObject(syntax.embeddedLanguages)) {
|
|
422
422
|
collector.error(( localize(
|
|
423
|
-
|
|
423
|
+
12860,
|
|
424
424
|
"Invalid value in `contributes.{0}.embeddedLanguages`. Must be an object map from scope name to language. Provided value: {1}",
|
|
425
425
|
grammarsExtPoint.name,
|
|
426
426
|
JSON.stringify(syntax.embeddedLanguages)
|
|
@@ -429,7 +429,7 @@ function validateGrammarExtensionPoint(extensionLocation, syntax, collector, _la
|
|
|
429
429
|
}
|
|
430
430
|
if (syntax.tokenTypes && !isObject(syntax.tokenTypes)) {
|
|
431
431
|
collector.error(( localize(
|
|
432
|
-
|
|
432
|
+
12861,
|
|
433
433
|
"Invalid value in `contributes.{0}.tokenTypes`. Must be an object map from scope name to token type. Provided value: {1}",
|
|
434
434
|
grammarsExtPoint.name,
|
|
435
435
|
JSON.stringify(syntax.tokenTypes)
|
|
@@ -439,7 +439,7 @@ function validateGrammarExtensionPoint(extensionLocation, syntax, collector, _la
|
|
|
439
439
|
const grammarLocation = joinPath(extensionLocation, syntax.path);
|
|
440
440
|
if (!isEqualOrParent(grammarLocation, extensionLocation)) {
|
|
441
441
|
collector.warn(( localize(
|
|
442
|
-
|
|
442
|
+
12862,
|
|
443
443
|
"Expected `contributes.{0}.path` ({1}) to be included inside extension's folder ({2}). This might make the extension non-portable.",
|
|
444
444
|
grammarsExtPoint.name,
|
|
445
445
|
grammarLocation.path,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { nullTokenizeEncoded } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/languages/nullTokenize';
|
|
3
3
|
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
4
4
|
import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
|
|
5
|
-
import { keepObserved } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/utils';
|
|
5
|
+
import { keepObserved } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/utils/utils';
|
|
6
6
|
|
|
7
7
|
class TokenizationSupportWithLineLimit extends Disposable {
|
|
8
8
|
get backgroundTokenizerShouldOnlyVerifyTokens() {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
3
|
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
4
4
|
import { ExtensionsRegistry } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensionsRegistry';
|
|
5
|
-
import { getTokenClassificationRegistry, typeAndModifierIdPattern } from '@codingame/monaco-vscode-
|
|
5
|
+
import { getTokenClassificationRegistry, typeAndModifierIdPattern } from '@codingame/monaco-vscode-93784a59-b4cf-520c-8339-f8104d3a4f3e-common/vscode/vs/platform/theme/common/tokenClassificationRegistry';
|
|
6
6
|
import { registerWorkbenchContribution2, WorkbenchPhase } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions';
|
|
7
7
|
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
8
8
|
|
|
@@ -10,26 +10,26 @@ const tokenClassificationRegistry = getTokenClassificationRegistry();
|
|
|
10
10
|
const tokenTypeExtPoint = ExtensionsRegistry.registerExtensionPoint({
|
|
11
11
|
extensionPoint: 'semanticTokenTypes',
|
|
12
12
|
jsonSchema: {
|
|
13
|
-
description: ( localize(
|
|
13
|
+
description: ( localize(13059, 'Contributes semantic token types.')),
|
|
14
14
|
type: 'array',
|
|
15
15
|
items: {
|
|
16
16
|
type: 'object',
|
|
17
17
|
properties: {
|
|
18
18
|
id: {
|
|
19
19
|
type: 'string',
|
|
20
|
-
description: ( localize(
|
|
20
|
+
description: ( localize(13060, 'The identifier of the semantic token type')),
|
|
21
21
|
pattern: typeAndModifierIdPattern,
|
|
22
|
-
patternErrorMessage: ( localize(
|
|
22
|
+
patternErrorMessage: ( localize(13061, 'Identifiers should be in the form letterOrDigit[_-letterOrDigit]*')),
|
|
23
23
|
},
|
|
24
24
|
superType: {
|
|
25
25
|
type: 'string',
|
|
26
|
-
description: ( localize(
|
|
26
|
+
description: ( localize(13062, 'The super type of the semantic token type')),
|
|
27
27
|
pattern: typeAndModifierIdPattern,
|
|
28
|
-
patternErrorMessage: ( localize(
|
|
28
|
+
patternErrorMessage: ( localize(13063, 'Super types should be in the form letterOrDigit[_-letterOrDigit]*')),
|
|
29
29
|
},
|
|
30
30
|
description: {
|
|
31
31
|
type: 'string',
|
|
32
|
-
description: ( localize(
|
|
32
|
+
description: ( localize(13064, 'The description of the semantic token type')),
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -38,20 +38,20 @@ const tokenTypeExtPoint = ExtensionsRegistry.registerExtensionPoint({
|
|
|
38
38
|
const tokenModifierExtPoint = ExtensionsRegistry.registerExtensionPoint({
|
|
39
39
|
extensionPoint: 'semanticTokenModifiers',
|
|
40
40
|
jsonSchema: {
|
|
41
|
-
description: ( localize(
|
|
41
|
+
description: ( localize(13065, 'Contributes semantic token modifiers.')),
|
|
42
42
|
type: 'array',
|
|
43
43
|
items: {
|
|
44
44
|
type: 'object',
|
|
45
45
|
properties: {
|
|
46
46
|
id: {
|
|
47
47
|
type: 'string',
|
|
48
|
-
description: ( localize(
|
|
48
|
+
description: ( localize(13066, 'The identifier of the semantic token modifier')),
|
|
49
49
|
pattern: typeAndModifierIdPattern,
|
|
50
|
-
patternErrorMessage: ( localize(
|
|
50
|
+
patternErrorMessage: ( localize(13067, 'Identifiers should be in the form letterOrDigit[_-letterOrDigit]*'))
|
|
51
51
|
},
|
|
52
52
|
description: {
|
|
53
53
|
type: 'string',
|
|
54
|
-
description: ( localize(
|
|
54
|
+
description: ( localize(13068, 'The description of the semantic token modifier'))
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
}
|
|
@@ -60,18 +60,18 @@ const tokenModifierExtPoint = ExtensionsRegistry.registerExtensionPoint({
|
|
|
60
60
|
const tokenStyleDefaultsExtPoint = ExtensionsRegistry.registerExtensionPoint({
|
|
61
61
|
extensionPoint: 'semanticTokenScopes',
|
|
62
62
|
jsonSchema: {
|
|
63
|
-
description: ( localize(
|
|
63
|
+
description: ( localize(13069, 'Contributes semantic token scope maps.')),
|
|
64
64
|
type: 'array',
|
|
65
65
|
items: {
|
|
66
66
|
type: 'object',
|
|
67
67
|
properties: {
|
|
68
68
|
language: {
|
|
69
|
-
description: ( localize(
|
|
69
|
+
description: ( localize(13070, 'Lists the languge for which the defaults are.')),
|
|
70
70
|
type: 'string'
|
|
71
71
|
},
|
|
72
72
|
scopes: {
|
|
73
73
|
description: ( localize(
|
|
74
|
-
|
|
74
|
+
13071,
|
|
75
75
|
'Maps a semantic token (described by semantic token selector) to one or more textMate scopes used to represent that token.'
|
|
76
76
|
)),
|
|
77
77
|
type: 'object',
|
|
@@ -91,7 +91,7 @@ class TokenClassificationExtensionPoints {
|
|
|
91
91
|
function validateTypeOrModifier(contribution, extensionPoint, collector) {
|
|
92
92
|
if (typeof contribution.id !== 'string' || contribution.id.length === 0) {
|
|
93
93
|
collector.error(( localize(
|
|
94
|
-
|
|
94
|
+
13072,
|
|
95
95
|
"'configuration.{0}.id' must be defined and can not be empty",
|
|
96
96
|
extensionPoint
|
|
97
97
|
)));
|
|
@@ -99,7 +99,7 @@ class TokenClassificationExtensionPoints {
|
|
|
99
99
|
}
|
|
100
100
|
if (!contribution.id.match(typeAndModifierIdPattern)) {
|
|
101
101
|
collector.error(( localize(
|
|
102
|
-
|
|
102
|
+
13073,
|
|
103
103
|
"'configuration.{0}.id' must follow the pattern letterOrDigit[-_letterOrDigit]*",
|
|
104
104
|
extensionPoint
|
|
105
105
|
)));
|
|
@@ -108,7 +108,7 @@ class TokenClassificationExtensionPoints {
|
|
|
108
108
|
const superType = contribution.superType;
|
|
109
109
|
if (superType && !superType.match(typeAndModifierIdPattern)) {
|
|
110
110
|
collector.error(( localize(
|
|
111
|
-
|
|
111
|
+
13074,
|
|
112
112
|
"'configuration.{0}.superType' must follow the pattern letterOrDigit[-_letterOrDigit]*",
|
|
113
113
|
extensionPoint
|
|
114
114
|
)));
|
|
@@ -116,7 +116,7 @@ class TokenClassificationExtensionPoints {
|
|
|
116
116
|
}
|
|
117
117
|
if (typeof contribution.description !== 'string' || contribution.id.length === 0) {
|
|
118
118
|
collector.error(( localize(
|
|
119
|
-
|
|
119
|
+
13075,
|
|
120
120
|
"'configuration.{0}.description' must be defined and can not be empty",
|
|
121
121
|
extensionPoint
|
|
122
122
|
)));
|
|
@@ -129,7 +129,7 @@ class TokenClassificationExtensionPoints {
|
|
|
129
129
|
const extensionValue = extension.value;
|
|
130
130
|
const collector = extension.collector;
|
|
131
131
|
if (!extensionValue || !Array.isArray(extensionValue)) {
|
|
132
|
-
collector.error(( localize(
|
|
132
|
+
collector.error(( localize(13076, "'configuration.semanticTokenType' must be an array")));
|
|
133
133
|
return;
|
|
134
134
|
}
|
|
135
135
|
for (const contribution of extensionValue) {
|
|
@@ -150,7 +150,7 @@ class TokenClassificationExtensionPoints {
|
|
|
150
150
|
const extensionValue = extension.value;
|
|
151
151
|
const collector = extension.collector;
|
|
152
152
|
if (!extensionValue || !Array.isArray(extensionValue)) {
|
|
153
|
-
collector.error(( localize(
|
|
153
|
+
collector.error(( localize(13077, "'configuration.semanticTokenModifier' must be an array")));
|
|
154
154
|
return;
|
|
155
155
|
}
|
|
156
156
|
for (const contribution of extensionValue) {
|
|
@@ -171,17 +171,17 @@ class TokenClassificationExtensionPoints {
|
|
|
171
171
|
const extensionValue = extension.value;
|
|
172
172
|
const collector = extension.collector;
|
|
173
173
|
if (!extensionValue || !Array.isArray(extensionValue)) {
|
|
174
|
-
collector.error(( localize(
|
|
174
|
+
collector.error(( localize(13078, "'configuration.semanticTokenScopes' must be an array")));
|
|
175
175
|
return;
|
|
176
176
|
}
|
|
177
177
|
for (const contribution of extensionValue) {
|
|
178
178
|
if (contribution.language && typeof contribution.language !== 'string') {
|
|
179
|
-
collector.error(( localize(
|
|
179
|
+
collector.error(( localize(13079, "'configuration.semanticTokenScopes.language' must be a string")));
|
|
180
180
|
continue;
|
|
181
181
|
}
|
|
182
182
|
if (!contribution.scopes || typeof contribution.scopes !== 'object') {
|
|
183
183
|
collector.error(( localize(
|
|
184
|
-
|
|
184
|
+
13080,
|
|
185
185
|
"'configuration.semanticTokenScopes.scopes' must be defined as an object"
|
|
186
186
|
)));
|
|
187
187
|
continue;
|
|
@@ -190,7 +190,7 @@ class TokenClassificationExtensionPoints {
|
|
|
190
190
|
const tmScopes = contribution.scopes[selectorString];
|
|
191
191
|
if (!Array.isArray(tmScopes) || ( tmScopes.some(l => typeof l !== 'string'))) {
|
|
192
192
|
collector.error(( localize(
|
|
193
|
-
|
|
193
|
+
13081,
|
|
194
194
|
"'configuration.semanticTokenScopes.scopes' values must be an array of strings"
|
|
195
195
|
)));
|
|
196
196
|
continue;
|
|
@@ -201,7 +201,7 @@ class TokenClassificationExtensionPoints {
|
|
|
201
201
|
}
|
|
202
202
|
catch (e) {
|
|
203
203
|
collector.error(( localize(
|
|
204
|
-
|
|
204
|
+
13082,
|
|
205
205
|
"configuration.semanticTokenScopes.scopes': Problems parsing selector {0}.",
|
|
206
206
|
selectorString
|
|
207
207
|
)));
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { compareBy, numberComparator } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
|
|
3
|
-
|
|
4
|
-
class ArrayEdit {
|
|
5
|
-
constructor(
|
|
6
|
-
edits) {
|
|
7
|
-
this.edits = edits.slice().sort(compareBy(c => c.offset, numberComparator));
|
|
8
|
-
}
|
|
9
|
-
applyToArray(array) {
|
|
10
|
-
for (let i = this.edits.length - 1; i >= 0; i--) {
|
|
11
|
-
const c = this.edits[i];
|
|
12
|
-
array.splice(c.offset, c.length, ...( new Array(c.newLength)));
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
class SingleArrayEdit {
|
|
17
|
-
constructor(offset, length, newLength) {
|
|
18
|
-
this.offset = offset;
|
|
19
|
-
this.length = length;
|
|
20
|
-
this.newLength = newLength;
|
|
21
|
-
}
|
|
22
|
-
toString() {
|
|
23
|
-
return `[${this.offset}, +${this.length}) -> +${this.newLength}}`;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
class MonotonousIndexTransformer {
|
|
27
|
-
static fromMany(transformations) {
|
|
28
|
-
const transformers = ( transformations.map(t => ( new MonotonousIndexTransformer(t))));
|
|
29
|
-
return ( new CombinedIndexTransformer(transformers));
|
|
30
|
-
}
|
|
31
|
-
constructor(transformation) {
|
|
32
|
-
this.transformation = transformation;
|
|
33
|
-
this.idx = 0;
|
|
34
|
-
this.offset = 0;
|
|
35
|
-
}
|
|
36
|
-
transform(index) {
|
|
37
|
-
let nextChange = this.transformation.edits[this.idx];
|
|
38
|
-
while (nextChange && nextChange.offset + nextChange.length <= index) {
|
|
39
|
-
this.offset += nextChange.newLength - nextChange.length;
|
|
40
|
-
this.idx++;
|
|
41
|
-
nextChange = this.transformation.edits[this.idx];
|
|
42
|
-
}
|
|
43
|
-
if (nextChange && nextChange.offset <= index) {
|
|
44
|
-
return undefined;
|
|
45
|
-
}
|
|
46
|
-
return index + this.offset;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
class CombinedIndexTransformer {
|
|
50
|
-
constructor(transformers) {
|
|
51
|
-
this.transformers = transformers;
|
|
52
|
-
}
|
|
53
|
-
transform(index) {
|
|
54
|
-
for (const transformer of this.transformers) {
|
|
55
|
-
const result = transformer.transform(index);
|
|
56
|
-
if (result === undefined) {
|
|
57
|
-
return undefined;
|
|
58
|
-
}
|
|
59
|
-
index = result;
|
|
60
|
-
}
|
|
61
|
-
return index;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export { ArrayEdit, CombinedIndexTransformer, MonotonousIndexTransformer, SingleArrayEdit };
|