@codingame/monaco-vscode-textmate-service-override 9.0.2 → 10.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 +3 -3
- package/textmate.js +5 -2
- package/vscode/src/vs/amdX.js +0 -2
- package/vscode/src/vs/workbench/services/textMate/browser/backgroundTokenization/textMateWorkerTokenizerController.js +4 -3
- package/vscode/src/vs/workbench/services/textMate/browser/backgroundTokenization/threadedBackgroundTokenizerFactory.js +0 -1
- package/vscode/src/vs/workbench/services/textMate/browser/backgroundTokenization/worker/textMateTokenizationWorker.worker.js +2 -2
- package/vscode/src/vs/workbench/services/textMate/browser/backgroundTokenization/worker/textMateWorkerTokenizer.js +6 -5
- package/vscode/src/vs/workbench/services/textMate/browser/textMateTokenizationFeatureImpl.js +20 -24
- package/vscode/src/vs/workbench/services/textMate/browser/tokenizationSupport/tokenizationSupportWithLineLimit.js +3 -2
- package/vscode/src/vs/workbench/services/themes/common/tokenClassificationExtensionPoint.js +26 -26
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/inspectEditorTokens/inspectEditorTokens.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/inspectEditorTokens/inspectEditorTokens.js +0 -548
- package/vscode/src/vs/workbench/services/textMate/common/TMHelper.js +0 -108
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-textmate-service-override",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "CodinGame",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"vscode": "npm:@codingame/monaco-vscode-api@
|
|
32
|
+
"vscode": "npm:@codingame/monaco-vscode-api@10.0.0",
|
|
33
33
|
"vscode-oniguruma": "1.7.0",
|
|
34
34
|
"vscode-textmate": "9.1.0",
|
|
35
|
-
"@codingame/monaco-vscode-files-service-override": "
|
|
35
|
+
"@codingame/monaco-vscode-files-service-override": "10.0.0"
|
|
36
36
|
}
|
|
37
37
|
}
|
package/textmate.js
CHANGED
|
@@ -8,7 +8,7 @@ import getServiceOverride$1 from '@codingame/monaco-vscode-files-service-overrid
|
|
|
8
8
|
import { registerServiceInitializeParticipant } from 'vscode/lifecycle';
|
|
9
9
|
import { registerAssets } from 'vscode/assets';
|
|
10
10
|
import './vscode/src/vs/workbench/services/themes/common/tokenClassificationExtensionPoint.js';
|
|
11
|
-
import '
|
|
11
|
+
import 'vscode/vscode/vs/workbench/contrib/codeEditor/browser/inspectEditorTokens/inspectEditorTokens';
|
|
12
12
|
|
|
13
13
|
const _onigWasm = new URL('vscode-oniguruma/release/onig.wasm', import.meta.url).href;
|
|
14
14
|
registerAssets({
|
|
@@ -16,7 +16,10 @@ registerAssets({
|
|
|
16
16
|
'vs/../../node_modules/vscode-oniguruma/release/onig.wasm': _onigWasm
|
|
17
17
|
});
|
|
18
18
|
registerServiceInitializeParticipant(async (accessor) => {
|
|
19
|
-
void accessor
|
|
19
|
+
void accessor
|
|
20
|
+
.get(ILifecycleService)
|
|
21
|
+
.when(2 )
|
|
22
|
+
.then(() => {
|
|
20
23
|
StandaloneServices.get(ITextMateTokenizationService);
|
|
21
24
|
});
|
|
22
25
|
});
|
package/vscode/src/vs/amdX.js
CHANGED
|
@@ -2,8 +2,6 @@ import { isESM } from 'vscode/vscode/vs/base/common/amd';
|
|
|
2
2
|
import { nodeModulesPath, FileAccess } from 'vscode/vscode/vs/base/common/network';
|
|
3
3
|
import 'vscode/vscode/vs/base/common/platform';
|
|
4
4
|
import { assertType } from 'vscode/vscode/vs/base/common/types';
|
|
5
|
-
import 'vscode/vscode/vs/base/common/charCode';
|
|
6
|
-
import 'vscode/vscode/vs/base/common/marshallingIds';
|
|
7
5
|
import 'vscode/vscode/vs/base/common/path';
|
|
8
6
|
|
|
9
7
|
function resolveAmdNodeModulePath(nodeModuleName, pathInsideNodeModule) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
2
2
|
import 'vscode/vscode/vs/base/common/arrays';
|
|
3
|
-
import 'vscode/vscode/vs/base/common/
|
|
3
|
+
import 'vscode/vscode/vs/base/common/event';
|
|
4
4
|
import { autorun } from 'vscode/vscode/vs/base/common/observableInternal/autorun';
|
|
5
|
-
import
|
|
5
|
+
import 'vscode/vscode/vs/base/common/observableInternal/derived';
|
|
6
6
|
import 'vscode/vscode/vs/base/common/cancellation';
|
|
7
|
+
import { keepObserved } from 'vscode/vscode/vs/base/common/observableInternal/utils';
|
|
7
8
|
import { countEOL } from 'vscode/vscode/vs/editor/common/core/eolCounter';
|
|
8
9
|
import { LineRange } from 'vscode/vscode/vs/editor/common/core/lineRange';
|
|
9
10
|
import { Range } from 'vscode/vscode/vs/editor/common/core/range';
|
|
@@ -11,7 +12,6 @@ import { TokenizationStateStore } from 'vscode/vscode/vs/editor/common/model/tex
|
|
|
11
12
|
import { ContiguousMultilineTokensBuilder } from 'vscode/vscode/vs/editor/common/tokens/contiguousMultilineTokensBuilder';
|
|
12
13
|
import { observableConfigValue } from 'vscode/vscode/vs/platform/observable/common/platformObservableUtils';
|
|
13
14
|
import { MonotonousIndexTransformer, ArrayEdit, SingleArrayEdit } from '../arrayOperation.js';
|
|
14
|
-
import { applyStateStackDiff, INITIAL } from 'vscode-textmate';
|
|
15
15
|
|
|
16
16
|
class TextMateWorkerTokenizerController extends Disposable {
|
|
17
17
|
static { this._id = 0; }
|
|
@@ -114,6 +114,7 @@ class TextMateWorkerTokenizerController extends Disposable {
|
|
|
114
114
|
}
|
|
115
115
|
const curToFutureTransformerStates = MonotonousIndexTransformer.fromMany(( this._pendingChanges.map((c) => fullLineArrayEditFromModelContentChange(c.changes))));
|
|
116
116
|
if (!this._applyStateStackDiffFn || !this._initialState) {
|
|
117
|
+
const { applyStateStackDiff, INITIAL } = await import('vscode-textmate').then(module => module.default ?? module);
|
|
117
118
|
this._applyStateStackDiffFn = applyStateStackDiff;
|
|
118
119
|
this._initialState = INITIAL;
|
|
119
120
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
-
import 'vscode/vscode/vs/base/common/amd';
|
|
3
2
|
import { DisposableStore, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
4
3
|
import { nodeModulesPath, FileAccess } from 'vscode/vscode/vs/base/common/network';
|
|
5
4
|
import 'vscode/vscode/vs/base/common/platform';
|
|
@@ -2,8 +2,6 @@ import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
|
2
2
|
import { TMGrammarFactory } from '../../../common/TMGrammarFactory.js';
|
|
3
3
|
import { TextMateWorkerTokenizer } from './textMateWorkerTokenizer.js';
|
|
4
4
|
import { TextMateWorkerHost } from './textMateWorkerHost.js';
|
|
5
|
-
import * as vscodeTextmate from 'vscode-textmate';
|
|
6
|
-
import * as vscodeOniguruma from 'vscode-oniguruma';
|
|
7
5
|
|
|
8
6
|
function create(workerServer) {
|
|
9
7
|
return ( new TextMateTokenizationWorker(workerServer));
|
|
@@ -32,6 +30,8 @@ class TextMateTokenizationWorker {
|
|
|
32
30
|
this._grammarFactory = this._loadTMGrammarFactory(grammarDefinitions, _createData.onigurumaWASMUri);
|
|
33
31
|
}
|
|
34
32
|
async _loadTMGrammarFactory(grammarDefinitions, onigurumaWASMUri) {
|
|
33
|
+
const vscodeTextmate = await import('vscode-textmate').then(module => module.default ?? module);
|
|
34
|
+
const vscodeOniguruma = await import('vscode-oniguruma').then(module => module.default ?? module);
|
|
35
35
|
const response = await fetch(onigurumaWASMUri);
|
|
36
36
|
const bytes = await response.arrayBuffer();
|
|
37
37
|
await vscodeOniguruma.loadWASM(bytes);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { RunOnceScheduler } from 'vscode/vscode/vs/base/common/async';
|
|
2
2
|
import { observableValue } from 'vscode/vscode/vs/base/common/observableInternal/base';
|
|
3
|
-
import 'vscode/vscode/vs/base/common/
|
|
3
|
+
import 'vscode/vscode/vs/base/common/arrays';
|
|
4
|
+
import 'vscode/vscode/vs/base/common/event';
|
|
5
|
+
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
4
6
|
import 'vscode/vscode/vs/base/common/observableInternal/autorun';
|
|
5
|
-
import 'vscode/vscode/vs/base/common/observableInternal/
|
|
7
|
+
import 'vscode/vscode/vs/base/common/observableInternal/derived';
|
|
6
8
|
import 'vscode/vscode/vs/base/common/cancellation';
|
|
7
|
-
import 'vscode/vscode/vs/base/common/
|
|
9
|
+
import 'vscode/vscode/vs/base/common/observableInternal/utils';
|
|
8
10
|
import { setTimeout0 } from 'vscode/vscode/vs/base/common/platform';
|
|
9
11
|
import { LineRange } from 'vscode/vscode/vs/editor/common/core/lineRange';
|
|
10
12
|
import { MirrorTextModel } from 'vscode/vscode/vs/editor/common/model/mirrorTextModel';
|
|
@@ -13,8 +15,6 @@ import { ContiguousMultilineTokensBuilder } from 'vscode/vscode/vs/editor/common
|
|
|
13
15
|
import { LineTokens } from 'vscode/vscode/vs/editor/common/tokens/lineTokens';
|
|
14
16
|
import { TextMateTokenizationSupport } from '../../tokenizationSupport/textMateTokenizationSupport.js';
|
|
15
17
|
import { TokenizationSupportWithLineLimit } from '../../tokenizationSupport/tokenizationSupportWithLineLimit.js';
|
|
16
|
-
import { diffStateStacksRefEq } from 'vscode-textmate';
|
|
17
|
-
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
18
18
|
|
|
19
19
|
class TextMateWorkerTokenizer extends MirrorTextModel {
|
|
20
20
|
constructor(uri, lines, eol, versionId, _host, _languageId, _encodedLanguageId, maxTokenizationLineLength) {
|
|
@@ -84,6 +84,7 @@ class TextMateWorkerTokenizer extends MirrorTextModel {
|
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
86
86
|
if (!this._diffStateStacksRefEqFn) {
|
|
87
|
+
const { diffStateStacksRefEq } = await import('vscode-textmate').then(module => module.default ?? module);
|
|
87
88
|
this._diffStateStacksRefEqFn = diffStateStacksRefEq;
|
|
88
89
|
}
|
|
89
90
|
const startTime = ( new Date()).getTime();
|
package/vscode/src/vs/workbench/services/textMate/browser/textMateTokenizationFeatureImpl.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
2
|
import { resolveAmdNodeModulePath } from '../../../../amdX.js';
|
|
3
|
-
import 'vscode/vscode/vs/base/common/amd';
|
|
4
3
|
import { createStyleSheet } from 'vscode/vscode/vs/base/browser/dom';
|
|
5
4
|
import { equals } from 'vscode/vscode/vs/base/common/arrays';
|
|
6
5
|
import { Color } from 'vscode/vscode/vs/base/common/color';
|
|
7
6
|
import { onUnexpectedError } from 'vscode/vscode/vs/base/common/errors';
|
|
8
7
|
import { Disposable, DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
9
8
|
import { FileAccess, nodeModulesPath } from 'vscode/vscode/vs/base/common/network';
|
|
10
|
-
import 'vscode/vscode/vs/base/common/
|
|
9
|
+
import 'vscode/vscode/vs/base/common/event';
|
|
11
10
|
import 'vscode/vscode/vs/base/common/observableInternal/autorun';
|
|
12
|
-
import
|
|
11
|
+
import 'vscode/vscode/vs/base/common/observableInternal/derived';
|
|
13
12
|
import 'vscode/vscode/vs/base/common/cancellation';
|
|
13
|
+
import { observableFromEvent } from 'vscode/vscode/vs/base/common/observableInternal/utils';
|
|
14
14
|
import { isWeb } from 'vscode/vscode/vs/base/common/platform';
|
|
15
15
|
import { joinPath, isEqualOrParent } from 'vscode/vscode/vs/base/common/resources';
|
|
16
16
|
import { isObject } from 'vscode/vscode/vs/base/common/types';
|
|
17
|
-
import { StandardTokenType } from 'vscode/vscode/vs/editor/common/encodedTokenAttributes';
|
|
18
17
|
import { LazyTokenizationSupport, TokenizationRegistry } from 'vscode/vscode/vs/editor/common/languages';
|
|
19
18
|
import { ILanguageService } from 'vscode/vscode/vs/editor/common/languages/language';
|
|
20
19
|
import { generateTokensCSSForColorMap } from 'vscode/vscode/vs/editor/common/languages/supports/tokenization';
|
|
@@ -24,7 +23,6 @@ import { IExtensionResourceLoaderService } from 'vscode/vscode/vs/platform/exten
|
|
|
24
23
|
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
25
24
|
import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
|
|
26
25
|
import { INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification.service';
|
|
27
|
-
import { ProgressLocation } from 'vscode/vscode/vs/platform/progress/common/progress';
|
|
28
26
|
import { IProgressService } from 'vscode/vscode/vs/platform/progress/common/progress.service';
|
|
29
27
|
import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry.service';
|
|
30
28
|
import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService.service';
|
|
@@ -34,8 +32,6 @@ import { ThreadedBackgroundTokenizerFactory } from './backgroundTokenization/thr
|
|
|
34
32
|
import { TMGrammarFactory, missingTMGrammarErrorMessage } from '../common/TMGrammarFactory.js';
|
|
35
33
|
import { grammarsExtPoint } from 'vscode/vscode/vs/workbench/services/textMate/common/TMGrammars';
|
|
36
34
|
import { IWorkbenchThemeService } from 'vscode/vscode/vs/workbench/services/themes/common/workbenchThemeService.service';
|
|
37
|
-
import * as vscodeTextmate from 'vscode-textmate';
|
|
38
|
-
import * as vscodeOniguruma from 'vscode-oniguruma';
|
|
39
35
|
|
|
40
36
|
var TextMateTokenizationFeature_1;
|
|
41
37
|
let TextMateTokenizationFeature = class TextMateTokenizationFeature extends Disposable {
|
|
@@ -134,13 +130,13 @@ let TextMateTokenizationFeature = class TextMateTokenizationFeature extends Disp
|
|
|
134
130
|
const tokenType = grammar.tokenTypes[scope];
|
|
135
131
|
switch (tokenType) {
|
|
136
132
|
case 'string':
|
|
137
|
-
tokenTypes[scope] =
|
|
133
|
+
tokenTypes[scope] = 2 ;
|
|
138
134
|
break;
|
|
139
135
|
case 'other':
|
|
140
|
-
tokenTypes[scope] =
|
|
136
|
+
tokenTypes[scope] = 0 ;
|
|
141
137
|
break;
|
|
142
138
|
case 'comment':
|
|
143
|
-
tokenTypes[scope] =
|
|
139
|
+
tokenTypes[scope] = 1 ;
|
|
144
140
|
break;
|
|
145
141
|
}
|
|
146
142
|
}
|
|
@@ -169,23 +165,23 @@ let TextMateTokenizationFeature = class TextMateTokenizationFeature extends Disp
|
|
|
169
165
|
}
|
|
170
166
|
startDebugMode(printFn, onStop) {
|
|
171
167
|
if (this._debugMode) {
|
|
172
|
-
this._notificationService.error(( localize(
|
|
168
|
+
this._notificationService.error(( localize(3082, "Already Logging.")));
|
|
173
169
|
return;
|
|
174
170
|
}
|
|
175
171
|
this._debugModePrintFunc = printFn;
|
|
176
172
|
this._debugMode = true;
|
|
177
173
|
if (this._debugMode) {
|
|
178
174
|
this._progressService.withProgress({
|
|
179
|
-
location:
|
|
180
|
-
buttons: [( localize(
|
|
175
|
+
location: 15 ,
|
|
176
|
+
buttons: [( localize(3083, "Stop"))]
|
|
181
177
|
}, (progress) => {
|
|
182
178
|
progress.report({
|
|
183
|
-
message: ( localize(
|
|
179
|
+
message: ( localize(3084, "Preparing to log TM Grammar parsing. Press Stop when finished."))
|
|
184
180
|
});
|
|
185
181
|
return this._getVSCodeOniguruma().then((vscodeOniguruma) => {
|
|
186
182
|
vscodeOniguruma.setDefaultDebugCall(true);
|
|
187
183
|
progress.report({
|
|
188
|
-
message: ( localize(
|
|
184
|
+
message: ( localize(3085, "Now logging TM Grammar parsing. Press Stop when finished."))
|
|
189
185
|
});
|
|
190
186
|
return (
|
|
191
187
|
(new Promise((resolve, reject) => { }))
|
|
@@ -208,7 +204,7 @@ let TextMateTokenizationFeature = class TextMateTokenizationFeature extends Disp
|
|
|
208
204
|
if (this._grammarFactory) {
|
|
209
205
|
return this._grammarFactory;
|
|
210
206
|
}
|
|
211
|
-
const vscodeOniguruma = await this._getVSCodeOniguruma();
|
|
207
|
+
const [vscodeTextmate, vscodeOniguruma] = await Promise.all([import('vscode-textmate').then(module => module.default ?? module), this._getVSCodeOniguruma()]);
|
|
212
208
|
const onigLib = Promise.resolve({
|
|
213
209
|
createOnigScanner: (sources) => vscodeOniguruma.createOnigScanner(sources),
|
|
214
210
|
createOnigString: (str) => vscodeOniguruma.createOnigString(str)
|
|
@@ -303,7 +299,7 @@ let TextMateTokenizationFeature = class TextMateTokenizationFeature extends Disp
|
|
|
303
299
|
_getVSCodeOniguruma() {
|
|
304
300
|
if (!this._vscodeOniguruma) {
|
|
305
301
|
this._vscodeOniguruma = (async () => {
|
|
306
|
-
const wasm = await this._loadVSCodeOnigurumaWASM();
|
|
302
|
+
const [vscodeOniguruma, wasm] = await Promise.all([import('vscode-oniguruma').then(module => module.default ?? module), this._loadVSCodeOnigurumaWASM()]);
|
|
307
303
|
await vscodeOniguruma.loadWASM({
|
|
308
304
|
data: wasm,
|
|
309
305
|
print: (str) => {
|
|
@@ -393,7 +389,7 @@ function equalsTokenRules(a, b) {
|
|
|
393
389
|
function validateGrammarExtensionPoint(extensionLocation, syntax, collector, _languageService) {
|
|
394
390
|
if (syntax.language && ((typeof syntax.language !== 'string') || !_languageService.isRegisteredLanguageId(syntax.language))) {
|
|
395
391
|
collector.error(( localize(
|
|
396
|
-
|
|
392
|
+
3086,
|
|
397
393
|
"Unknown language in `contributes.{0}.language`. Provided value: {1}",
|
|
398
394
|
grammarsExtPoint.name,
|
|
399
395
|
String(syntax.language)
|
|
@@ -402,7 +398,7 @@ function validateGrammarExtensionPoint(extensionLocation, syntax, collector, _la
|
|
|
402
398
|
}
|
|
403
399
|
if (!syntax.scopeName || (typeof syntax.scopeName !== 'string')) {
|
|
404
400
|
collector.error(( localize(
|
|
405
|
-
|
|
401
|
+
3087,
|
|
406
402
|
"Expected string in `contributes.{0}.scopeName`. Provided value: {1}",
|
|
407
403
|
grammarsExtPoint.name,
|
|
408
404
|
String(syntax.scopeName)
|
|
@@ -411,7 +407,7 @@ function validateGrammarExtensionPoint(extensionLocation, syntax, collector, _la
|
|
|
411
407
|
}
|
|
412
408
|
if (!syntax.path || (typeof syntax.path !== 'string')) {
|
|
413
409
|
collector.error(( localize(
|
|
414
|
-
|
|
410
|
+
3088,
|
|
415
411
|
"Expected string in `contributes.{0}.path`. Provided value: {1}",
|
|
416
412
|
grammarsExtPoint.name,
|
|
417
413
|
String(syntax.path)
|
|
@@ -420,7 +416,7 @@ function validateGrammarExtensionPoint(extensionLocation, syntax, collector, _la
|
|
|
420
416
|
}
|
|
421
417
|
if (syntax.injectTo && (!Array.isArray(syntax.injectTo) || ( (syntax.injectTo.some(scope => typeof scope !== 'string'))))) {
|
|
422
418
|
collector.error(( localize(
|
|
423
|
-
|
|
419
|
+
3089,
|
|
424
420
|
"Invalid value in `contributes.{0}.injectTo`. Must be an array of language scope names. Provided value: {1}",
|
|
425
421
|
grammarsExtPoint.name,
|
|
426
422
|
JSON.stringify(syntax.injectTo)
|
|
@@ -429,7 +425,7 @@ function validateGrammarExtensionPoint(extensionLocation, syntax, collector, _la
|
|
|
429
425
|
}
|
|
430
426
|
if (syntax.embeddedLanguages && !isObject(syntax.embeddedLanguages)) {
|
|
431
427
|
collector.error(( localize(
|
|
432
|
-
|
|
428
|
+
3090,
|
|
433
429
|
"Invalid value in `contributes.{0}.embeddedLanguages`. Must be an object map from scope name to language. Provided value: {1}",
|
|
434
430
|
grammarsExtPoint.name,
|
|
435
431
|
JSON.stringify(syntax.embeddedLanguages)
|
|
@@ -438,7 +434,7 @@ function validateGrammarExtensionPoint(extensionLocation, syntax, collector, _la
|
|
|
438
434
|
}
|
|
439
435
|
if (syntax.tokenTypes && !isObject(syntax.tokenTypes)) {
|
|
440
436
|
collector.error(( localize(
|
|
441
|
-
|
|
437
|
+
3091,
|
|
442
438
|
"Invalid value in `contributes.{0}.tokenTypes`. Must be an object map from scope name to token type. Provided value: {1}",
|
|
443
439
|
grammarsExtPoint.name,
|
|
444
440
|
JSON.stringify(syntax.tokenTypes)
|
|
@@ -448,7 +444,7 @@ function validateGrammarExtensionPoint(extensionLocation, syntax, collector, _la
|
|
|
448
444
|
const grammarLocation = joinPath(extensionLocation, syntax.path);
|
|
449
445
|
if (!isEqualOrParent(grammarLocation, extensionLocation)) {
|
|
450
446
|
collector.warn(( localize(
|
|
451
|
-
|
|
447
|
+
3092,
|
|
452
448
|
"Expected `contributes.{0}.path` ({1}) to be included inside extension's folder ({2}). This might make the extension non-portable.",
|
|
453
449
|
grammarsExtPoint.name,
|
|
454
450
|
grammarLocation.path,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { nullTokenizeEncoded } from 'vscode/vscode/vs/editor/common/languages/nullTokenize';
|
|
2
2
|
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
3
3
|
import 'vscode/vscode/vs/base/common/arrays';
|
|
4
|
-
import 'vscode/vscode/vs/base/common/
|
|
4
|
+
import 'vscode/vscode/vs/base/common/event';
|
|
5
5
|
import 'vscode/vscode/vs/base/common/observableInternal/autorun';
|
|
6
|
-
import
|
|
6
|
+
import 'vscode/vscode/vs/base/common/observableInternal/derived';
|
|
7
7
|
import 'vscode/vscode/vs/base/common/cancellation';
|
|
8
|
+
import { keepObserved } from 'vscode/vscode/vs/base/common/observableInternal/utils';
|
|
8
9
|
|
|
9
10
|
class TokenizationSupportWithLineLimit extends Disposable {
|
|
10
11
|
get backgroundTokenizerShouldOnlyVerifyTokens() {
|
|
@@ -2,33 +2,33 @@ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
|
2
2
|
import { localize } from 'vscode/vscode/vs/nls';
|
|
3
3
|
import { ExtensionsRegistry } from 'vscode/vscode/vs/workbench/services/extensions/common/extensionsRegistry';
|
|
4
4
|
import { getTokenClassificationRegistry, typeAndModifierIdPattern } from 'vscode/vscode/vs/platform/theme/common/tokenClassificationRegistry';
|
|
5
|
+
import { registerWorkbenchContribution2 } from 'vscode/vscode/vs/workbench/common/contributions';
|
|
5
6
|
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
6
|
-
import { registerWorkbenchContribution2, WorkbenchPhase } from 'vscode/vscode/vs/workbench/common/contributions';
|
|
7
7
|
|
|
8
8
|
const tokenClassificationRegistry = getTokenClassificationRegistry();
|
|
9
9
|
const tokenTypeExtPoint = ExtensionsRegistry.registerExtensionPoint({
|
|
10
10
|
extensionPoint: 'semanticTokenTypes',
|
|
11
11
|
jsonSchema: {
|
|
12
|
-
description: ( localize(
|
|
12
|
+
description: ( localize(3093, 'Contributes semantic token types.')),
|
|
13
13
|
type: 'array',
|
|
14
14
|
items: {
|
|
15
15
|
type: 'object',
|
|
16
16
|
properties: {
|
|
17
17
|
id: {
|
|
18
18
|
type: 'string',
|
|
19
|
-
description: ( localize(
|
|
19
|
+
description: ( localize(3094, 'The identifier of the semantic token type')),
|
|
20
20
|
pattern: typeAndModifierIdPattern,
|
|
21
|
-
patternErrorMessage: ( localize(
|
|
21
|
+
patternErrorMessage: ( localize(3095, 'Identifiers should be in the form letterOrDigit[_-letterOrDigit]*')),
|
|
22
22
|
},
|
|
23
23
|
superType: {
|
|
24
24
|
type: 'string',
|
|
25
|
-
description: ( localize(
|
|
25
|
+
description: ( localize(3096, 'The super type of the semantic token type')),
|
|
26
26
|
pattern: typeAndModifierIdPattern,
|
|
27
|
-
patternErrorMessage: ( localize(
|
|
27
|
+
patternErrorMessage: ( localize(3097, 'Super types should be in the form letterOrDigit[_-letterOrDigit]*')),
|
|
28
28
|
},
|
|
29
29
|
description: {
|
|
30
30
|
type: 'string',
|
|
31
|
-
description: ( localize(
|
|
31
|
+
description: ( localize(3098, 'The description of the semantic token type')),
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -37,20 +37,20 @@ const tokenTypeExtPoint = ExtensionsRegistry.registerExtensionPoint({
|
|
|
37
37
|
const tokenModifierExtPoint = ExtensionsRegistry.registerExtensionPoint({
|
|
38
38
|
extensionPoint: 'semanticTokenModifiers',
|
|
39
39
|
jsonSchema: {
|
|
40
|
-
description: ( localize(
|
|
40
|
+
description: ( localize(3099, 'Contributes semantic token modifiers.')),
|
|
41
41
|
type: 'array',
|
|
42
42
|
items: {
|
|
43
43
|
type: 'object',
|
|
44
44
|
properties: {
|
|
45
45
|
id: {
|
|
46
46
|
type: 'string',
|
|
47
|
-
description: ( localize(
|
|
47
|
+
description: ( localize(3100, 'The identifier of the semantic token modifier')),
|
|
48
48
|
pattern: typeAndModifierIdPattern,
|
|
49
|
-
patternErrorMessage: ( localize(
|
|
49
|
+
patternErrorMessage: ( localize(3101, 'Identifiers should be in the form letterOrDigit[_-letterOrDigit]*'))
|
|
50
50
|
},
|
|
51
51
|
description: {
|
|
52
52
|
type: 'string',
|
|
53
|
-
description: ( localize(
|
|
53
|
+
description: ( localize(3102, 'The description of the semantic token modifier'))
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -59,18 +59,18 @@ const tokenModifierExtPoint = ExtensionsRegistry.registerExtensionPoint({
|
|
|
59
59
|
const tokenStyleDefaultsExtPoint = ExtensionsRegistry.registerExtensionPoint({
|
|
60
60
|
extensionPoint: 'semanticTokenScopes',
|
|
61
61
|
jsonSchema: {
|
|
62
|
-
description: ( localize(
|
|
62
|
+
description: ( localize(3103, 'Contributes semantic token scope maps.')),
|
|
63
63
|
type: 'array',
|
|
64
64
|
items: {
|
|
65
65
|
type: 'object',
|
|
66
66
|
properties: {
|
|
67
67
|
language: {
|
|
68
|
-
description: ( localize(
|
|
68
|
+
description: ( localize(3104, 'Lists the languge for which the defaults are.')),
|
|
69
69
|
type: 'string'
|
|
70
70
|
},
|
|
71
71
|
scopes: {
|
|
72
72
|
description: ( localize(
|
|
73
|
-
|
|
73
|
+
3105,
|
|
74
74
|
'Maps a semantic token (described by semantic token selector) to one or more textMate scopes used to represent that token.'
|
|
75
75
|
)),
|
|
76
76
|
type: 'object',
|
|
@@ -90,7 +90,7 @@ class TokenClassificationExtensionPoints {
|
|
|
90
90
|
function validateTypeOrModifier(contribution, extensionPoint, collector) {
|
|
91
91
|
if (typeof contribution.id !== 'string' || contribution.id.length === 0) {
|
|
92
92
|
collector.error(( localize(
|
|
93
|
-
|
|
93
|
+
3106,
|
|
94
94
|
"'configuration.{0}.id' must be defined and can not be empty",
|
|
95
95
|
extensionPoint
|
|
96
96
|
)));
|
|
@@ -98,7 +98,7 @@ class TokenClassificationExtensionPoints {
|
|
|
98
98
|
}
|
|
99
99
|
if (!contribution.id.match(typeAndModifierIdPattern)) {
|
|
100
100
|
collector.error(( localize(
|
|
101
|
-
|
|
101
|
+
3107,
|
|
102
102
|
"'configuration.{0}.id' must follow the pattern letterOrDigit[-_letterOrDigit]*",
|
|
103
103
|
extensionPoint
|
|
104
104
|
)));
|
|
@@ -107,7 +107,7 @@ class TokenClassificationExtensionPoints {
|
|
|
107
107
|
const superType = contribution.superType;
|
|
108
108
|
if (superType && !superType.match(typeAndModifierIdPattern)) {
|
|
109
109
|
collector.error(( localize(
|
|
110
|
-
|
|
110
|
+
3108,
|
|
111
111
|
"'configuration.{0}.superType' must follow the pattern letterOrDigit[-_letterOrDigit]*",
|
|
112
112
|
extensionPoint
|
|
113
113
|
)));
|
|
@@ -115,7 +115,7 @@ class TokenClassificationExtensionPoints {
|
|
|
115
115
|
}
|
|
116
116
|
if (typeof contribution.description !== 'string' || contribution.id.length === 0) {
|
|
117
117
|
collector.error(( localize(
|
|
118
|
-
|
|
118
|
+
3109,
|
|
119
119
|
"'configuration.{0}.description' must be defined and can not be empty",
|
|
120
120
|
extensionPoint
|
|
121
121
|
)));
|
|
@@ -128,7 +128,7 @@ class TokenClassificationExtensionPoints {
|
|
|
128
128
|
const extensionValue = extension.value;
|
|
129
129
|
const collector = extension.collector;
|
|
130
130
|
if (!extensionValue || !Array.isArray(extensionValue)) {
|
|
131
|
-
collector.error(( localize(
|
|
131
|
+
collector.error(( localize(3110, "'configuration.semanticTokenType' must be an array")));
|
|
132
132
|
return;
|
|
133
133
|
}
|
|
134
134
|
for (const contribution of extensionValue) {
|
|
@@ -149,7 +149,7 @@ class TokenClassificationExtensionPoints {
|
|
|
149
149
|
const extensionValue = extension.value;
|
|
150
150
|
const collector = extension.collector;
|
|
151
151
|
if (!extensionValue || !Array.isArray(extensionValue)) {
|
|
152
|
-
collector.error(( localize(
|
|
152
|
+
collector.error(( localize(3111, "'configuration.semanticTokenModifier' must be an array")));
|
|
153
153
|
return;
|
|
154
154
|
}
|
|
155
155
|
for (const contribution of extensionValue) {
|
|
@@ -170,17 +170,17 @@ class TokenClassificationExtensionPoints {
|
|
|
170
170
|
const extensionValue = extension.value;
|
|
171
171
|
const collector = extension.collector;
|
|
172
172
|
if (!extensionValue || !Array.isArray(extensionValue)) {
|
|
173
|
-
collector.error(( localize(
|
|
173
|
+
collector.error(( localize(3112, "'configuration.semanticTokenScopes' must be an array")));
|
|
174
174
|
return;
|
|
175
175
|
}
|
|
176
176
|
for (const contribution of extensionValue) {
|
|
177
177
|
if (contribution.language && typeof contribution.language !== 'string') {
|
|
178
|
-
collector.error(( localize(
|
|
178
|
+
collector.error(( localize(3113, "'configuration.semanticTokenScopes.language' must be a string")));
|
|
179
179
|
continue;
|
|
180
180
|
}
|
|
181
181
|
if (!contribution.scopes || typeof contribution.scopes !== 'object') {
|
|
182
182
|
collector.error(( localize(
|
|
183
|
-
|
|
183
|
+
3114,
|
|
184
184
|
"'configuration.semanticTokenScopes.scopes' must be defined as an object"
|
|
185
185
|
)));
|
|
186
186
|
continue;
|
|
@@ -189,7 +189,7 @@ class TokenClassificationExtensionPoints {
|
|
|
189
189
|
const tmScopes = contribution.scopes[selectorString];
|
|
190
190
|
if (!Array.isArray(tmScopes) || ( (tmScopes.some(l => typeof l !== 'string')))) {
|
|
191
191
|
collector.error(( localize(
|
|
192
|
-
|
|
192
|
+
3115,
|
|
193
193
|
"'configuration.semanticTokenScopes.scopes' values must be an array of strings"
|
|
194
194
|
)));
|
|
195
195
|
continue;
|
|
@@ -200,7 +200,7 @@ class TokenClassificationExtensionPoints {
|
|
|
200
200
|
}
|
|
201
201
|
catch (e) {
|
|
202
202
|
collector.error(( localize(
|
|
203
|
-
|
|
203
|
+
3116,
|
|
204
204
|
"configuration.semanticTokenScopes.scopes': Problems parsing selector {0}.",
|
|
205
205
|
selectorString
|
|
206
206
|
)));
|
|
@@ -235,6 +235,6 @@ let TokenClassificationExtensionPointWorkbenchContribution = class TokenClassifi
|
|
|
235
235
|
TokenClassificationExtensionPointWorkbenchContribution = ( (__decorate([
|
|
236
236
|
( (__param(0, IInstantiationService)))
|
|
237
237
|
], TokenClassificationExtensionPointWorkbenchContribution)));
|
|
238
|
-
registerWorkbenchContribution2(TokenClassificationExtensionPointWorkbenchContribution.ID, TokenClassificationExtensionPointWorkbenchContribution,
|
|
238
|
+
registerWorkbenchContribution2(TokenClassificationExtensionPointWorkbenchContribution.ID, TokenClassificationExtensionPointWorkbenchContribution, 1 );
|
|
239
239
|
|
|
240
240
|
export { TokenClassificationExtensionPoints };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import n from 'vscode/external/rollup-plugin-styles/dist/runtime/inject-css.js';
|
|
2
|
-
|
|
3
|
-
var css = ".token-inspect-widget{border:1px solid var(--vscode-editorHoverWidget-border);padding:10px;user-select:text;-webkit-user-select:text;z-index:50}.hc-black .tokens-inspect-widget,.hc-light .tokens-inspect-widget{border-width:2px}.monaco-editor .token-inspect-widget{background-color:var(--vscode-editorHoverWidget-background)}.monaco-editor .token-inspect-widget .tiw-metadata-separator{background-color:var(--vscode-editorHoverWidget-border)}.tiw-token{font-family:var(--monaco-monospace-font)}.tiw-metadata-separator{border:0;height:1px}.tiw-token-length{float:right;font-size:60%;font-weight:400}.tiw-metadata-table{width:100%}.tiw-metadata-value{font-family:var(--monaco-monospace-font);word-break:break-word}.tiw-metadata-values{list-style:none;margin-right:-10px;max-height:300px;overflow-y:auto;padding-left:0}.tiw-metadata-values>.tiw-metadata-value{margin-right:10px}.tiw-metadata-key{min-width:150px;padding-right:10px;vertical-align:top;white-space:nowrap;width:1px}.tiw-metadata-semantic{font-style:italic}.tiw-metadata-scopes{line-height:normal}.tiw-theme-selector{font-family:var(--monaco-monospace-font)}";
|
|
4
|
-
n(css,{});
|
|
5
|
-
|
|
6
|
-
export { css, css as default };
|
|
@@ -1,548 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
-
import './inspectEditorTokens.css.js';
|
|
3
|
-
import { localize } from 'vscode/vscode/vs/nls';
|
|
4
|
-
import { $ as $$1, clearNode, reset, append, isHTMLElement } from 'vscode/vscode/vs/base/browser/dom';
|
|
5
|
-
import { CharCode } from 'vscode/vscode/vs/base/common/charCode';
|
|
6
|
-
import { Color } from 'vscode/vscode/vs/base/common/color';
|
|
7
|
-
import { KeyCode } from 'vscode/vscode/vs/base/common/keyCodes';
|
|
8
|
-
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
9
|
-
import { ContentWidgetPositionPreference } from 'vscode/vscode/vs/editor/browser/editorBrowser';
|
|
10
|
-
import { EditorAction, registerEditorContribution, EditorContributionInstantiation, registerEditorAction } from 'vscode/vscode/vs/editor/browser/editorExtensions';
|
|
11
|
-
import { Range } from 'vscode/vscode/vs/editor/common/core/range';
|
|
12
|
-
import { TreeSitterTokenizationRegistry } from 'vscode/vscode/vs/editor/common/languages';
|
|
13
|
-
import { StandardTokenType, TokenMetadata, FontStyle, ColorId } from 'vscode/vscode/vs/editor/common/encodedTokenAttributes';
|
|
14
|
-
import { ILanguageService } from 'vscode/vscode/vs/editor/common/languages/language';
|
|
15
|
-
import { INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification.service';
|
|
16
|
-
import { findMatchingThemeRule } from '../../../../services/textMate/common/TMHelper.js';
|
|
17
|
-
import { ITextMateTokenizationService } from 'vscode/vscode/vs/workbench/services/textMate/browser/textMateTokenizationFeature.service';
|
|
18
|
-
import { IWorkbenchThemeService } from 'vscode/vscode/vs/workbench/services/themes/common/workbenchThemeService.service';
|
|
19
|
-
import { CancellationTokenSource } from 'vscode/vscode/vs/base/common/cancellation';
|
|
20
|
-
import { SemanticTokenRule } from 'vscode/vscode/vs/platform/theme/common/tokenClassificationRegistry';
|
|
21
|
-
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
|
|
22
|
-
import { SEMANTIC_HIGHLIGHTING_SETTING_ID } from 'vscode/vscode/vs/editor/contrib/semanticTokens/common/semanticTokensConfig';
|
|
23
|
-
import { Schemas } from 'vscode/vscode/vs/base/common/network';
|
|
24
|
-
import { ILanguageFeaturesService } from 'vscode/vscode/vs/editor/common/services/languageFeatures';
|
|
25
|
-
import { ITreeSitterParserService } from 'vscode/vscode/vs/editor/common/services/treeSitterParserService';
|
|
26
|
-
|
|
27
|
-
var InspectEditorTokensController_1;
|
|
28
|
-
const $ = $$1;
|
|
29
|
-
let InspectEditorTokensController = class InspectEditorTokensController extends Disposable {
|
|
30
|
-
static { InspectEditorTokensController_1 = this; }
|
|
31
|
-
static { this.ID = 'editor.contrib.inspectEditorTokens'; }
|
|
32
|
-
static get(editor) {
|
|
33
|
-
return editor.getContribution(InspectEditorTokensController_1.ID);
|
|
34
|
-
}
|
|
35
|
-
constructor(editor, textMateService, treeSitterService, languageService, themeService, notificationService, configurationService, languageFeaturesService) {
|
|
36
|
-
super();
|
|
37
|
-
this._editor = editor;
|
|
38
|
-
this._textMateService = textMateService;
|
|
39
|
-
this._treeSitterService = treeSitterService;
|
|
40
|
-
this._themeService = themeService;
|
|
41
|
-
this._languageService = languageService;
|
|
42
|
-
this._notificationService = notificationService;
|
|
43
|
-
this._configurationService = configurationService;
|
|
44
|
-
this._languageFeaturesService = languageFeaturesService;
|
|
45
|
-
this._widget = null;
|
|
46
|
-
this._register(this._editor.onDidChangeModel((e) => this.stop()));
|
|
47
|
-
this._register(this._editor.onDidChangeModelLanguage((e) => this.stop()));
|
|
48
|
-
this._register(this._editor.onKeyUp((e) => e.keyCode === KeyCode.Escape && this.stop()));
|
|
49
|
-
}
|
|
50
|
-
dispose() {
|
|
51
|
-
this.stop();
|
|
52
|
-
super.dispose();
|
|
53
|
-
}
|
|
54
|
-
launch() {
|
|
55
|
-
if (this._widget) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (!this._editor.hasModel()) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
if (this._editor.getModel().uri.scheme === Schemas.vscodeNotebookCell) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
this._widget = ( (new InspectEditorTokensWidget(
|
|
65
|
-
this._editor,
|
|
66
|
-
this._textMateService,
|
|
67
|
-
this._treeSitterService,
|
|
68
|
-
this._languageService,
|
|
69
|
-
this._themeService,
|
|
70
|
-
this._notificationService,
|
|
71
|
-
this._configurationService,
|
|
72
|
-
this._languageFeaturesService
|
|
73
|
-
)));
|
|
74
|
-
}
|
|
75
|
-
stop() {
|
|
76
|
-
if (this._widget) {
|
|
77
|
-
this._widget.dispose();
|
|
78
|
-
this._widget = null;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
toggle() {
|
|
82
|
-
if (!this._widget) {
|
|
83
|
-
this.launch();
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
this.stop();
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
InspectEditorTokensController = InspectEditorTokensController_1 = ( (__decorate([
|
|
91
|
-
( (__param(1, ITextMateTokenizationService))),
|
|
92
|
-
( (__param(2, ITreeSitterParserService))),
|
|
93
|
-
( (__param(3, ILanguageService))),
|
|
94
|
-
( (__param(4, IWorkbenchThemeService))),
|
|
95
|
-
( (__param(5, INotificationService))),
|
|
96
|
-
( (__param(6, IConfigurationService))),
|
|
97
|
-
( (__param(7, ILanguageFeaturesService)))
|
|
98
|
-
], InspectEditorTokensController)));
|
|
99
|
-
class InspectEditorTokens extends EditorAction {
|
|
100
|
-
constructor() {
|
|
101
|
-
super({
|
|
102
|
-
id: 'editor.action.inspectTMScopes',
|
|
103
|
-
label: ( localize(2806, "Developer: Inspect Editor Tokens and Scopes")),
|
|
104
|
-
alias: 'Developer: Inspect Editor Tokens and Scopes',
|
|
105
|
-
precondition: undefined
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
run(accessor, editor) {
|
|
109
|
-
const controller = InspectEditorTokensController.get(editor);
|
|
110
|
-
controller?.toggle();
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
function renderTokenText(tokenText) {
|
|
114
|
-
if (tokenText.length > 40) {
|
|
115
|
-
tokenText = tokenText.substr(0, 20) + '…' + tokenText.substr(tokenText.length - 20);
|
|
116
|
-
}
|
|
117
|
-
let result = '';
|
|
118
|
-
for (let charIndex = 0, len = tokenText.length; charIndex < len; charIndex++) {
|
|
119
|
-
const charCode = tokenText.charCodeAt(charIndex);
|
|
120
|
-
switch (charCode) {
|
|
121
|
-
case CharCode.Tab:
|
|
122
|
-
result += '\u2192';
|
|
123
|
-
break;
|
|
124
|
-
case CharCode.Space:
|
|
125
|
-
result += '\u00B7';
|
|
126
|
-
break;
|
|
127
|
-
default:
|
|
128
|
-
result += String.fromCharCode(charCode);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return result;
|
|
132
|
-
}
|
|
133
|
-
class InspectEditorTokensWidget extends Disposable {
|
|
134
|
-
static { this._ID = 'editor.contrib.inspectEditorTokensWidget'; }
|
|
135
|
-
constructor(editor, textMateService, treeSitterService, languageService, themeService, notificationService, configurationService, languageFeaturesService) {
|
|
136
|
-
super();
|
|
137
|
-
this.allowEditorOverflow = true;
|
|
138
|
-
this._isDisposed = false;
|
|
139
|
-
this._editor = editor;
|
|
140
|
-
this._languageService = languageService;
|
|
141
|
-
this._themeService = themeService;
|
|
142
|
-
this._textMateService = textMateService;
|
|
143
|
-
this._treeSitterService = treeSitterService;
|
|
144
|
-
this._notificationService = notificationService;
|
|
145
|
-
this._configurationService = configurationService;
|
|
146
|
-
this._languageFeaturesService = languageFeaturesService;
|
|
147
|
-
this._model = this._editor.getModel();
|
|
148
|
-
this._domNode = document.createElement('div');
|
|
149
|
-
this._domNode.className = 'token-inspect-widget';
|
|
150
|
-
this._currentRequestCancellationTokenSource = ( (new CancellationTokenSource()));
|
|
151
|
-
this._beginCompute(this._editor.getPosition());
|
|
152
|
-
this._register(this._editor.onDidChangeCursorPosition((e) => this._beginCompute(this._editor.getPosition())));
|
|
153
|
-
this._register(themeService.onDidColorThemeChange(_ => this._beginCompute(this._editor.getPosition())));
|
|
154
|
-
this._register(configurationService.onDidChangeConfiguration(e => e.affectsConfiguration('editor.semanticHighlighting.enabled') && this._beginCompute(this._editor.getPosition())));
|
|
155
|
-
this._editor.addContentWidget(this);
|
|
156
|
-
}
|
|
157
|
-
dispose() {
|
|
158
|
-
this._isDisposed = true;
|
|
159
|
-
this._editor.removeContentWidget(this);
|
|
160
|
-
this._currentRequestCancellationTokenSource.cancel();
|
|
161
|
-
super.dispose();
|
|
162
|
-
}
|
|
163
|
-
getId() {
|
|
164
|
-
return InspectEditorTokensWidget._ID;
|
|
165
|
-
}
|
|
166
|
-
_beginCompute(position) {
|
|
167
|
-
const grammar = this._textMateService.createTokenizer(this._model.getLanguageId());
|
|
168
|
-
const semanticTokens = this._computeSemanticTokens(position);
|
|
169
|
-
const tree = this._treeSitterService.getParseResult(this._model);
|
|
170
|
-
clearNode(this._domNode);
|
|
171
|
-
this._domNode.appendChild(document.createTextNode(( localize(2807, "Loading..."))));
|
|
172
|
-
Promise.all([grammar, semanticTokens]).then(([grammar, semanticTokens]) => {
|
|
173
|
-
if (this._isDisposed) {
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
this._compute(grammar, semanticTokens, tree?.tree, position);
|
|
177
|
-
this._domNode.style.maxWidth = `${Math.max(this._editor.getLayoutInfo().width * 0.66, 500)}px`;
|
|
178
|
-
this._editor.layoutContentWidget(this);
|
|
179
|
-
}, (err) => {
|
|
180
|
-
this._notificationService.warn(err);
|
|
181
|
-
setTimeout(() => {
|
|
182
|
-
InspectEditorTokensController.get(this._editor)?.stop();
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
_isSemanticColoringEnabled() {
|
|
187
|
-
const setting = this._configurationService.getValue(SEMANTIC_HIGHLIGHTING_SETTING_ID, { overrideIdentifier: this._model.getLanguageId(), resource: this._model.uri })?.enabled;
|
|
188
|
-
if (typeof setting === 'boolean') {
|
|
189
|
-
return setting;
|
|
190
|
-
}
|
|
191
|
-
return this._themeService.getColorTheme().semanticHighlighting;
|
|
192
|
-
}
|
|
193
|
-
_compute(grammar, semanticTokens, tree, position) {
|
|
194
|
-
const textMateTokenInfo = grammar && this._getTokensAtPosition(grammar, position);
|
|
195
|
-
const semanticTokenInfo = semanticTokens && this._getSemanticTokenAtPosition(semanticTokens, position);
|
|
196
|
-
const treeSitterTokenInfo = tree && this._getTreeSitterTokenAtPosition(tree, position);
|
|
197
|
-
if (!textMateTokenInfo && !semanticTokenInfo && !treeSitterTokenInfo) {
|
|
198
|
-
reset(this._domNode, 'No grammar or semantic tokens available.');
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
const tmMetadata = textMateTokenInfo?.metadata;
|
|
202
|
-
const semMetadata = semanticTokenInfo?.metadata;
|
|
203
|
-
const semTokenText = semanticTokenInfo && renderTokenText(this._model.getValueInRange(semanticTokenInfo.range));
|
|
204
|
-
const tmTokenText = textMateTokenInfo && renderTokenText(this._model.getLineContent(position.lineNumber).substring(textMateTokenInfo.token.startIndex, textMateTokenInfo.token.endIndex));
|
|
205
|
-
const tokenText = semTokenText || tmTokenText || '';
|
|
206
|
-
reset(this._domNode, $('h2.tiw-token', undefined, tokenText, $('span.tiw-token-length', undefined, `${tokenText.length} ${tokenText.length === 1 ? 'char' : 'chars'}`)));
|
|
207
|
-
append(this._domNode, $('hr.tiw-metadata-separator', { 'style': 'clear:both' }));
|
|
208
|
-
append(this._domNode, $('table.tiw-metadata-table', undefined, $('tbody', undefined, $('tr', undefined, $('td.tiw-metadata-key', undefined, 'language'), $('td.tiw-metadata-value', undefined, tmMetadata?.languageId || '')), $('tr', undefined, $('td.tiw-metadata-key', undefined, 'standard token type'), $('td.tiw-metadata-value', undefined, this._tokenTypeToString(tmMetadata?.tokenType || StandardTokenType.Other))), ...this._formatMetadata(semMetadata, tmMetadata))));
|
|
209
|
-
if (semanticTokenInfo) {
|
|
210
|
-
append(this._domNode, $('hr.tiw-metadata-separator'));
|
|
211
|
-
const table = append(this._domNode, $('table.tiw-metadata-table', undefined));
|
|
212
|
-
const tbody = append(table, $('tbody', undefined, $('tr', undefined, $('td.tiw-metadata-key', undefined, 'semantic token type'), $('td.tiw-metadata-value', undefined, semanticTokenInfo.type))));
|
|
213
|
-
if (semanticTokenInfo.modifiers.length) {
|
|
214
|
-
append(tbody, $('tr', undefined, $('td.tiw-metadata-key', undefined, 'modifiers'), $('td.tiw-metadata-value', undefined, semanticTokenInfo.modifiers.join(' '))));
|
|
215
|
-
}
|
|
216
|
-
if (semanticTokenInfo.metadata) {
|
|
217
|
-
const properties = ['foreground', 'bold', 'italic', 'underline', 'strikethrough'];
|
|
218
|
-
const propertiesByDefValue = {};
|
|
219
|
-
const allDefValues = ( (new Array()));
|
|
220
|
-
for (const property of properties) {
|
|
221
|
-
if (semanticTokenInfo.metadata[property] !== undefined) {
|
|
222
|
-
const definition = semanticTokenInfo.definitions[property];
|
|
223
|
-
const defValue = this._renderTokenStyleDefinition(definition, property);
|
|
224
|
-
const defValueStr = ( (defValue.map(el => isHTMLElement(el) ? el.outerHTML : el))).join();
|
|
225
|
-
let properties = propertiesByDefValue[defValueStr];
|
|
226
|
-
if (!properties) {
|
|
227
|
-
propertiesByDefValue[defValueStr] = properties = [];
|
|
228
|
-
allDefValues.push([defValue, defValueStr]);
|
|
229
|
-
}
|
|
230
|
-
properties.push(property);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
for (const [defValue, defValueStr] of allDefValues) {
|
|
234
|
-
append(tbody, $('tr', undefined, $('td.tiw-metadata-key', undefined, propertiesByDefValue[defValueStr].join(', ')), $('td.tiw-metadata-value', undefined, ...defValue)));
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
if (textMateTokenInfo) {
|
|
239
|
-
const theme = this._themeService.getColorTheme();
|
|
240
|
-
append(this._domNode, $('hr.tiw-metadata-separator'));
|
|
241
|
-
const table = append(this._domNode, $('table.tiw-metadata-table'));
|
|
242
|
-
const tbody = append(table, $('tbody'));
|
|
243
|
-
if (tmTokenText && tmTokenText !== tokenText) {
|
|
244
|
-
append(tbody, $('tr', undefined, $('td.tiw-metadata-key', undefined, 'textmate token'), $('td.tiw-metadata-value', undefined, `${tmTokenText} (${tmTokenText.length})`)));
|
|
245
|
-
}
|
|
246
|
-
const scopes = ( (new Array()));
|
|
247
|
-
for (let i = textMateTokenInfo.token.scopes.length - 1; i >= 0; i--) {
|
|
248
|
-
scopes.push(textMateTokenInfo.token.scopes[i]);
|
|
249
|
-
if (i > 0) {
|
|
250
|
-
scopes.push($('br'));
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
append(tbody, $('tr', undefined, $('td.tiw-metadata-key', undefined, 'textmate scopes'), $('td.tiw-metadata-value.tiw-metadata-scopes', undefined, ...scopes)));
|
|
254
|
-
const matchingRule = findMatchingThemeRule(theme, textMateTokenInfo.token.scopes, false);
|
|
255
|
-
const semForeground = semanticTokenInfo?.metadata?.foreground;
|
|
256
|
-
if (matchingRule) {
|
|
257
|
-
if (semForeground !== textMateTokenInfo.metadata.foreground) {
|
|
258
|
-
let defValue = $('code.tiw-theme-selector', undefined, matchingRule.rawSelector, $('br'), JSON.stringify(matchingRule.settings, null, '\t'));
|
|
259
|
-
if (semForeground) {
|
|
260
|
-
defValue = $('s', undefined, defValue);
|
|
261
|
-
}
|
|
262
|
-
append(tbody, $('tr', undefined, $('td.tiw-metadata-key', undefined, 'foreground'), $('td.tiw-metadata-value', undefined, defValue)));
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
else if (!semForeground) {
|
|
266
|
-
append(tbody, $('tr', undefined, $('td.tiw-metadata-key', undefined, 'foreground'), $('td.tiw-metadata-value', undefined, 'No theme selector')));
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
if (treeSitterTokenInfo) {
|
|
270
|
-
append(this._domNode, $('hr.tiw-metadata-separator'));
|
|
271
|
-
const table = append(this._domNode, $('table.tiw-metadata-table'));
|
|
272
|
-
const tbody = append(table, $('tbody'));
|
|
273
|
-
append(tbody, $('tr', undefined, $('td.tiw-metadata-key', undefined, 'tree-sitter token'), $('td.tiw-metadata-value', undefined, `${treeSitterTokenInfo.text}`)));
|
|
274
|
-
const scopes = ( (new Array()));
|
|
275
|
-
let node = treeSitterTokenInfo;
|
|
276
|
-
while (node.parent) {
|
|
277
|
-
scopes.push(node.type);
|
|
278
|
-
node = node.parent;
|
|
279
|
-
if (node) {
|
|
280
|
-
scopes.push($('br'));
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
append(tbody, $('tr', undefined, $('td.tiw-metadata-key', undefined, 'tree-sitter scopes'), $('td.tiw-metadata-value.tiw-metadata-scopes', undefined, ...scopes)));
|
|
284
|
-
const tokenizationSupport = TreeSitterTokenizationRegistry.get(this._model.getLanguageId());
|
|
285
|
-
const captures = tokenizationSupport?.captureAtPosition(position.lineNumber, position.column, this._model);
|
|
286
|
-
if (captures && captures.length > 0) {
|
|
287
|
-
append(tbody, $('tr', undefined, $('td.tiw-metadata-key', undefined, 'foreground'), $('td.tiw-metadata-value', undefined, captures[0].name)));
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
_formatMetadata(semantic, tm) {
|
|
292
|
-
const elements = ( (new Array()));
|
|
293
|
-
function render(property) {
|
|
294
|
-
const value = semantic?.[property] || tm?.[property];
|
|
295
|
-
if (value !== undefined) {
|
|
296
|
-
const semanticStyle = semantic?.[property] ? 'tiw-metadata-semantic' : '';
|
|
297
|
-
elements.push($('tr', undefined, $('td.tiw-metadata-key', undefined, property), $(`td.tiw-metadata-value.${semanticStyle}`, undefined, value)));
|
|
298
|
-
}
|
|
299
|
-
return value;
|
|
300
|
-
}
|
|
301
|
-
const foreground = render('foreground');
|
|
302
|
-
const background = render('background');
|
|
303
|
-
if (foreground && background) {
|
|
304
|
-
const backgroundColor = ( (Color.fromHex(background))), foregroundColor = ( (Color.fromHex(foreground)));
|
|
305
|
-
if (backgroundColor.isOpaque()) {
|
|
306
|
-
elements.push($('tr', undefined, $('td.tiw-metadata-key', undefined, 'contrast ratio'), $('td.tiw-metadata-value', undefined, backgroundColor.getContrastRatio(foregroundColor.makeOpaque(backgroundColor)).toFixed(2))));
|
|
307
|
-
}
|
|
308
|
-
else {
|
|
309
|
-
elements.push($('tr', undefined, $('td.tiw-metadata-key', undefined, 'Contrast ratio cannot be precise for background colors that use transparency'), $('td.tiw-metadata-value')));
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
const fontStyleLabels = ( (new Array()));
|
|
313
|
-
function addStyle(key) {
|
|
314
|
-
let label;
|
|
315
|
-
if (semantic && semantic[key]) {
|
|
316
|
-
label = $('span.tiw-metadata-semantic', undefined, key);
|
|
317
|
-
}
|
|
318
|
-
else if (tm && tm[key]) {
|
|
319
|
-
label = key;
|
|
320
|
-
}
|
|
321
|
-
if (label) {
|
|
322
|
-
if (fontStyleLabels.length) {
|
|
323
|
-
fontStyleLabels.push(' ');
|
|
324
|
-
}
|
|
325
|
-
fontStyleLabels.push(label);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
addStyle('bold');
|
|
329
|
-
addStyle('italic');
|
|
330
|
-
addStyle('underline');
|
|
331
|
-
addStyle('strikethrough');
|
|
332
|
-
if (fontStyleLabels.length) {
|
|
333
|
-
elements.push($('tr', undefined, $('td.tiw-metadata-key', undefined, 'font style'), $('td.tiw-metadata-value', undefined, ...fontStyleLabels)));
|
|
334
|
-
}
|
|
335
|
-
return elements;
|
|
336
|
-
}
|
|
337
|
-
_decodeMetadata(metadata) {
|
|
338
|
-
const colorMap = this._themeService.getColorTheme().tokenColorMap;
|
|
339
|
-
const languageId = TokenMetadata.getLanguageId(metadata);
|
|
340
|
-
const tokenType = TokenMetadata.getTokenType(metadata);
|
|
341
|
-
const fontStyle = TokenMetadata.getFontStyle(metadata);
|
|
342
|
-
const foreground = TokenMetadata.getForeground(metadata);
|
|
343
|
-
const background = TokenMetadata.getBackground(metadata);
|
|
344
|
-
return {
|
|
345
|
-
languageId: this._languageService.languageIdCodec.decodeLanguageId(languageId),
|
|
346
|
-
tokenType: tokenType,
|
|
347
|
-
bold: (fontStyle & FontStyle.Bold) ? true : undefined,
|
|
348
|
-
italic: (fontStyle & FontStyle.Italic) ? true : undefined,
|
|
349
|
-
underline: (fontStyle & FontStyle.Underline) ? true : undefined,
|
|
350
|
-
strikethrough: (fontStyle & FontStyle.Strikethrough) ? true : undefined,
|
|
351
|
-
foreground: colorMap[foreground],
|
|
352
|
-
background: colorMap[background]
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
_tokenTypeToString(tokenType) {
|
|
356
|
-
switch (tokenType) {
|
|
357
|
-
case StandardTokenType.Other: return 'Other';
|
|
358
|
-
case StandardTokenType.Comment: return 'Comment';
|
|
359
|
-
case StandardTokenType.String: return 'String';
|
|
360
|
-
case StandardTokenType.RegEx: return 'RegEx';
|
|
361
|
-
default: return '??';
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
_getTokensAtPosition(grammar, position) {
|
|
365
|
-
const lineNumber = position.lineNumber;
|
|
366
|
-
const stateBeforeLine = this._getStateBeforeLine(grammar, lineNumber);
|
|
367
|
-
const tokenizationResult1 = grammar.tokenizeLine(this._model.getLineContent(lineNumber), stateBeforeLine);
|
|
368
|
-
const tokenizationResult2 = grammar.tokenizeLine2(this._model.getLineContent(lineNumber), stateBeforeLine);
|
|
369
|
-
let token1Index = 0;
|
|
370
|
-
for (let i = tokenizationResult1.tokens.length - 1; i >= 0; i--) {
|
|
371
|
-
const t = tokenizationResult1.tokens[i];
|
|
372
|
-
if (position.column - 1 >= t.startIndex) {
|
|
373
|
-
token1Index = i;
|
|
374
|
-
break;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
let token2Index = 0;
|
|
378
|
-
for (let i = (tokenizationResult2.tokens.length >>> 1); i >= 0; i--) {
|
|
379
|
-
if (position.column - 1 >= tokenizationResult2.tokens[(i << 1)]) {
|
|
380
|
-
token2Index = i;
|
|
381
|
-
break;
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
return {
|
|
385
|
-
token: tokenizationResult1.tokens[token1Index],
|
|
386
|
-
metadata: this._decodeMetadata(tokenizationResult2.tokens[(token2Index << 1) + 1])
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
_getStateBeforeLine(grammar, lineNumber) {
|
|
390
|
-
let state = null;
|
|
391
|
-
for (let i = 1; i < lineNumber; i++) {
|
|
392
|
-
const tokenizationResult = grammar.tokenizeLine(this._model.getLineContent(i), state);
|
|
393
|
-
state = tokenizationResult.ruleStack;
|
|
394
|
-
}
|
|
395
|
-
return state;
|
|
396
|
-
}
|
|
397
|
-
isSemanticTokens(token) {
|
|
398
|
-
return token && token.data;
|
|
399
|
-
}
|
|
400
|
-
async _computeSemanticTokens(position) {
|
|
401
|
-
if (!this._isSemanticColoringEnabled()) {
|
|
402
|
-
return null;
|
|
403
|
-
}
|
|
404
|
-
const tokenProviders = this._languageFeaturesService.documentSemanticTokensProvider.ordered(this._model);
|
|
405
|
-
if (tokenProviders.length) {
|
|
406
|
-
const provider = tokenProviders[0];
|
|
407
|
-
const tokens = await Promise.resolve(provider.provideDocumentSemanticTokens(this._model, null, this._currentRequestCancellationTokenSource.token));
|
|
408
|
-
if (this.isSemanticTokens(tokens)) {
|
|
409
|
-
return { tokens, legend: provider.getLegend() };
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
const rangeTokenProviders = this._languageFeaturesService.documentRangeSemanticTokensProvider.ordered(this._model);
|
|
413
|
-
if (rangeTokenProviders.length) {
|
|
414
|
-
const provider = rangeTokenProviders[0];
|
|
415
|
-
const lineNumber = position.lineNumber;
|
|
416
|
-
const range = ( (new Range(lineNumber, 1, lineNumber, this._model.getLineMaxColumn(lineNumber))));
|
|
417
|
-
const tokens = await Promise.resolve(provider.provideDocumentRangeSemanticTokens(this._model, range, this._currentRequestCancellationTokenSource.token));
|
|
418
|
-
if (this.isSemanticTokens(tokens)) {
|
|
419
|
-
return { tokens, legend: provider.getLegend() };
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
return null;
|
|
423
|
-
}
|
|
424
|
-
_getSemanticTokenAtPosition(semanticTokens, pos) {
|
|
425
|
-
const tokenData = semanticTokens.tokens.data;
|
|
426
|
-
const defaultLanguage = this._model.getLanguageId();
|
|
427
|
-
let lastLine = 0;
|
|
428
|
-
let lastCharacter = 0;
|
|
429
|
-
const posLine = pos.lineNumber - 1, posCharacter = pos.column - 1;
|
|
430
|
-
for (let i = 0; i < tokenData.length; i += 5) {
|
|
431
|
-
const lineDelta = tokenData[i], charDelta = tokenData[i + 1], len = tokenData[i + 2], typeIdx = tokenData[i + 3], modSet = tokenData[i + 4];
|
|
432
|
-
const line = lastLine + lineDelta;
|
|
433
|
-
const character = lineDelta === 0 ? lastCharacter + charDelta : charDelta;
|
|
434
|
-
if (posLine === line && character <= posCharacter && posCharacter < character + len) {
|
|
435
|
-
const type = semanticTokens.legend.tokenTypes[typeIdx] || 'not in legend (ignored)';
|
|
436
|
-
const modifiers = [];
|
|
437
|
-
let modifierSet = modSet;
|
|
438
|
-
for (let modifierIndex = 0; modifierSet > 0 && modifierIndex < semanticTokens.legend.tokenModifiers.length; modifierIndex++) {
|
|
439
|
-
if (modifierSet & 1) {
|
|
440
|
-
modifiers.push(semanticTokens.legend.tokenModifiers[modifierIndex]);
|
|
441
|
-
}
|
|
442
|
-
modifierSet = modifierSet >> 1;
|
|
443
|
-
}
|
|
444
|
-
if (modifierSet > 0) {
|
|
445
|
-
modifiers.push('not in legend (ignored)');
|
|
446
|
-
}
|
|
447
|
-
const range = ( (new Range(line + 1, character + 1, line + 1, character + 1 + len)));
|
|
448
|
-
const definitions = {};
|
|
449
|
-
const colorMap = this._themeService.getColorTheme().tokenColorMap;
|
|
450
|
-
const theme = this._themeService.getColorTheme();
|
|
451
|
-
const tokenStyle = theme.getTokenStyleMetadata(type, modifiers, defaultLanguage, true, definitions);
|
|
452
|
-
let metadata = undefined;
|
|
453
|
-
if (tokenStyle) {
|
|
454
|
-
metadata = {
|
|
455
|
-
languageId: undefined,
|
|
456
|
-
tokenType: StandardTokenType.Other,
|
|
457
|
-
bold: tokenStyle?.bold,
|
|
458
|
-
italic: tokenStyle?.italic,
|
|
459
|
-
underline: tokenStyle?.underline,
|
|
460
|
-
strikethrough: tokenStyle?.strikethrough,
|
|
461
|
-
foreground: colorMap[tokenStyle?.foreground || ColorId.None],
|
|
462
|
-
background: undefined
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
return { type, modifiers, range, metadata, definitions };
|
|
466
|
-
}
|
|
467
|
-
lastLine = line;
|
|
468
|
-
lastCharacter = character;
|
|
469
|
-
}
|
|
470
|
-
return null;
|
|
471
|
-
}
|
|
472
|
-
_walkTreeforPosition(cursor, pos) {
|
|
473
|
-
const offset = this._model.getOffsetAt(pos);
|
|
474
|
-
cursor.gotoFirstChild();
|
|
475
|
-
let goChild = false;
|
|
476
|
-
let lastGoodNode = null;
|
|
477
|
-
do {
|
|
478
|
-
if (cursor.currentNode.startIndex <= offset && offset < cursor.currentNode.endIndex) {
|
|
479
|
-
goChild = true;
|
|
480
|
-
lastGoodNode = cursor.currentNode;
|
|
481
|
-
}
|
|
482
|
-
else {
|
|
483
|
-
goChild = false;
|
|
484
|
-
}
|
|
485
|
-
} while (goChild ? cursor.gotoFirstChild() : cursor.gotoNextSibling());
|
|
486
|
-
return lastGoodNode;
|
|
487
|
-
}
|
|
488
|
-
_getTreeSitterTokenAtPosition(tree, pos) {
|
|
489
|
-
const cursor = tree.walk();
|
|
490
|
-
return this._walkTreeforPosition(cursor, pos);
|
|
491
|
-
}
|
|
492
|
-
_renderTokenStyleDefinition(definition, property) {
|
|
493
|
-
const elements = ( (new Array()));
|
|
494
|
-
if (definition === undefined) {
|
|
495
|
-
return elements;
|
|
496
|
-
}
|
|
497
|
-
const theme = this._themeService.getColorTheme();
|
|
498
|
-
if (Array.isArray(definition)) {
|
|
499
|
-
const scopesDefinition = {};
|
|
500
|
-
theme.resolveScopes(definition, scopesDefinition);
|
|
501
|
-
const matchingRule = scopesDefinition[property];
|
|
502
|
-
if (matchingRule && scopesDefinition.scope) {
|
|
503
|
-
const scopes = $('ul.tiw-metadata-values');
|
|
504
|
-
const strScopes = Array.isArray(matchingRule.scope) ? matchingRule.scope : [String(matchingRule.scope)];
|
|
505
|
-
for (const strScope of strScopes) {
|
|
506
|
-
scopes.appendChild($('li.tiw-metadata-value.tiw-metadata-scopes', undefined, strScope));
|
|
507
|
-
}
|
|
508
|
-
elements.push(scopesDefinition.scope.join(' '), scopes, $('code.tiw-theme-selector', undefined, JSON.stringify(matchingRule.settings, null, '\t')));
|
|
509
|
-
return elements;
|
|
510
|
-
}
|
|
511
|
-
return elements;
|
|
512
|
-
}
|
|
513
|
-
else if (SemanticTokenRule.is(definition)) {
|
|
514
|
-
const scope = theme.getTokenStylingRuleScope(definition);
|
|
515
|
-
if (scope === 'setting') {
|
|
516
|
-
elements.push(`User settings: ${definition.selector.id} - ${this._renderStyleProperty(definition.style, property)}`);
|
|
517
|
-
return elements;
|
|
518
|
-
}
|
|
519
|
-
else if (scope === 'theme') {
|
|
520
|
-
elements.push(`Color theme: ${definition.selector.id} - ${this._renderStyleProperty(definition.style, property)}`);
|
|
521
|
-
return elements;
|
|
522
|
-
}
|
|
523
|
-
return elements;
|
|
524
|
-
}
|
|
525
|
-
else {
|
|
526
|
-
const style = theme.resolveTokenStyleValue(definition);
|
|
527
|
-
elements.push(`Default: ${style ? this._renderStyleProperty(style, property) : ''}`);
|
|
528
|
-
return elements;
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
_renderStyleProperty(style, property) {
|
|
532
|
-
switch (property) {
|
|
533
|
-
case 'foreground': return style.foreground ? Color.Format.CSS.formatHexA(style.foreground, true) : '';
|
|
534
|
-
default: return style[property] !== undefined ? String(style[property]) : '';
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
getDomNode() {
|
|
538
|
-
return this._domNode;
|
|
539
|
-
}
|
|
540
|
-
getPosition() {
|
|
541
|
-
return {
|
|
542
|
-
position: this._editor.getPosition(),
|
|
543
|
-
preference: [ContentWidgetPositionPreference.BELOW, ContentWidgetPositionPreference.ABOVE]
|
|
544
|
-
};
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
registerEditorContribution(InspectEditorTokensController.ID, InspectEditorTokensController, EditorContributionInstantiation.Lazy);
|
|
548
|
-
registerEditorAction(InspectEditorTokens);
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
function findMatchingThemeRule(theme, scopes, onlyColorRules = true) {
|
|
2
|
-
for (let i = scopes.length - 1; i >= 0; i--) {
|
|
3
|
-
const parentScopes = scopes.slice(0, i);
|
|
4
|
-
const scope = scopes[i];
|
|
5
|
-
const r = findMatchingThemeRule2(theme, scope, parentScopes, onlyColorRules);
|
|
6
|
-
if (r) {
|
|
7
|
-
return r;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
function findMatchingThemeRule2(theme, scope, parentScopes, onlyColorRules) {
|
|
13
|
-
let result = null;
|
|
14
|
-
for (let i = theme.tokenColors.length - 1; i >= 0; i--) {
|
|
15
|
-
const rule = theme.tokenColors[i];
|
|
16
|
-
if (onlyColorRules && !rule.settings.foreground) {
|
|
17
|
-
continue;
|
|
18
|
-
}
|
|
19
|
-
let selectors;
|
|
20
|
-
if (typeof rule.scope === 'string') {
|
|
21
|
-
selectors = ( rule.scope.split(/,/).map(scope => scope.trim()));
|
|
22
|
-
}
|
|
23
|
-
else if (Array.isArray(rule.scope)) {
|
|
24
|
-
selectors = rule.scope;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
for (let j = 0, lenJ = selectors.length; j < lenJ; j++) {
|
|
30
|
-
const rawSelector = selectors[j];
|
|
31
|
-
const themeRule = ( new ThemeRule(rawSelector, rule.settings));
|
|
32
|
-
if (themeRule.matches(scope, parentScopes)) {
|
|
33
|
-
if (themeRule.isMoreSpecific(result)) {
|
|
34
|
-
result = themeRule;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return result;
|
|
40
|
-
}
|
|
41
|
-
class ThemeRule {
|
|
42
|
-
constructor(rawSelector, settings) {
|
|
43
|
-
this.rawSelector = rawSelector;
|
|
44
|
-
this.settings = settings;
|
|
45
|
-
const rawSelectorPieces = this.rawSelector.split(/ /);
|
|
46
|
-
this.scope = rawSelectorPieces[rawSelectorPieces.length - 1];
|
|
47
|
-
this.parentScopes = rawSelectorPieces.slice(0, rawSelectorPieces.length - 1);
|
|
48
|
-
}
|
|
49
|
-
matches(scope, parentScopes) {
|
|
50
|
-
return ThemeRule._matches(this.scope, this.parentScopes, scope, parentScopes);
|
|
51
|
-
}
|
|
52
|
-
static _cmp(a, b) {
|
|
53
|
-
if (a === null && b === null) {
|
|
54
|
-
return 0;
|
|
55
|
-
}
|
|
56
|
-
if (a === null) {
|
|
57
|
-
return -1;
|
|
58
|
-
}
|
|
59
|
-
if (b === null) {
|
|
60
|
-
return 1;
|
|
61
|
-
}
|
|
62
|
-
if (a.scope.length !== b.scope.length) {
|
|
63
|
-
return a.scope.length - b.scope.length;
|
|
64
|
-
}
|
|
65
|
-
const aParentScopesLen = a.parentScopes.length;
|
|
66
|
-
const bParentScopesLen = b.parentScopes.length;
|
|
67
|
-
if (aParentScopesLen !== bParentScopesLen) {
|
|
68
|
-
return aParentScopesLen - bParentScopesLen;
|
|
69
|
-
}
|
|
70
|
-
for (let i = 0; i < aParentScopesLen; i++) {
|
|
71
|
-
const aLen = a.parentScopes[i].length;
|
|
72
|
-
const bLen = b.parentScopes[i].length;
|
|
73
|
-
if (aLen !== bLen) {
|
|
74
|
-
return aLen - bLen;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return 0;
|
|
78
|
-
}
|
|
79
|
-
isMoreSpecific(other) {
|
|
80
|
-
return (ThemeRule._cmp(this, other) > 0);
|
|
81
|
-
}
|
|
82
|
-
static _matchesOne(selectorScope, scope) {
|
|
83
|
-
const selectorPrefix = selectorScope + '.';
|
|
84
|
-
if (selectorScope === scope || scope.substring(0, selectorPrefix.length) === selectorPrefix) {
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
static _matches(selectorScope, selectorParentScopes, scope, parentScopes) {
|
|
90
|
-
if (!this._matchesOne(selectorScope, scope)) {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
let selectorParentIndex = selectorParentScopes.length - 1;
|
|
94
|
-
let parentIndex = parentScopes.length - 1;
|
|
95
|
-
while (selectorParentIndex >= 0 && parentIndex >= 0) {
|
|
96
|
-
if (this._matchesOne(selectorParentScopes[selectorParentIndex], parentScopes[parentIndex])) {
|
|
97
|
-
selectorParentIndex--;
|
|
98
|
-
}
|
|
99
|
-
parentIndex--;
|
|
100
|
-
}
|
|
101
|
-
if (selectorParentIndex === -1) {
|
|
102
|
-
return true;
|
|
103
|
-
}
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export { ThemeRule, findMatchingThemeRule };
|