@codingame/monaco-vscode-api 4.5.0-improve-code-splitting.1 → 4.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -8
- package/editor.api.d.ts +8 -0
- package/localExtensionHost.d.ts +41 -0
- package/package.json +10 -8
- package/service-override/accessibility.d.ts +5 -0
- package/service-override/ai.d.ts +5 -0
- package/service-override/authentication.d.ts +5 -0
- package/service-override/base.d.ts +5 -0
- package/service-override/bulkEdit.d.ts +5 -0
- package/service-override/chat.d.ts +5 -0
- package/service-override/comments.d.ts +5 -0
- package/service-override/configuration.d.ts +31 -0
- package/service-override/debug.d.ts +5 -0
- package/service-override/dialogs.d.ts +12 -0
- package/service-override/editSessions.d.ts +5 -0
- package/service-override/editor.d.ts +10 -0
- package/service-override/emmet.d.ts +5 -0
- package/service-override/environment.d.ts +10 -0
- package/service-override/explorer.d.ts +5 -0
- package/service-override/extensionGallery.d.ts +12 -0
- package/service-override/extensions.d.ts +43 -0
- package/service-override/files.d.ts +164 -0
- package/service-override/host.d.ts +5 -0
- package/service-override/interactive.d.ts +5 -0
- package/service-override/issue.d.ts +5 -0
- package/service-override/keybindings.d.ts +21 -0
- package/service-override/languageDetectionWorker.d.ts +5 -0
- package/service-override/languages.d.ts +6 -0
- package/service-override/layout.d.ts +128 -0
- package/service-override/lifecycle.d.ts +5 -0
- package/service-override/localization.d.ts +14 -0
- package/service-override/log.d.ts +14 -0
- package/service-override/markers.d.ts +5 -0
- package/service-override/model.d.ts +5 -0
- package/service-override/monarch.d.ts +5 -0
- package/service-override/multiDiffEditor.d.ts +5 -0
- package/service-override/notebook.d.ts +5 -0
- package/service-override/notifications.d.ts +5 -0
- package/service-override/outline.d.ts +5 -0
- package/service-override/output.d.ts +10 -0
- package/service-override/performance.d.ts +5 -0
- package/service-override/preferences.d.ts +5 -0
- package/service-override/quickaccess.d.ts +11 -0
- package/service-override/relauncher.d.ts +5 -0
- package/service-override/remoteAgent.d.ts +12 -0
- package/service-override/scm.d.ts +5 -0
- package/service-override/search.d.ts +12 -0
- package/service-override/secretStorage.d.ts +5 -0
- package/service-override/share.d.ts +5 -0
- package/service-override/snippets.d.ts +9 -0
- package/service-override/speech.d.ts +5 -0
- package/service-override/storage.d.ts +66 -0
- package/service-override/survey.d.ts +5 -0
- package/service-override/task.d.ts +5 -0
- package/service-override/terminal.d.ts +71 -0
- package/service-override/testing.d.ts +5 -0
- package/service-override/textmate.d.ts +6 -0
- package/service-override/theme.d.ts +7 -0
- package/service-override/timeline.d.ts +5 -0
- package/service-override/update.d.ts +5 -0
- package/service-override/userDataSync.d.ts +5 -0
- package/service-override/viewBanner.d.ts +6 -0
- package/service-override/viewCommon.d.ts +6 -0
- package/service-override/viewStatusBar.d.ts +6 -0
- package/service-override/viewTitleBar.d.ts +5 -0
- package/service-override/views.d.ts +47 -0
- package/service-override/walkthrough.d.ts +5 -0
- package/service-override/welcome.d.ts +5 -0
- package/service-override/workbench.d.ts +18 -0
- package/service-override/workingCopy.d.ts +5 -0
- package/service-override/workspaceTrust.d.ts +5 -0
- package/services.js +0 -1
- package/vscode/src/vs/base/browser/indexedDB.d.ts +17 -0
- package/vscode/src/vs/base/browser/ui/toolbar/toolbar.d.ts +62 -0
- package/vscode/src/vs/base/common/worker/simpleWorker.js +2 -6
- package/vscode/src/vs/editor/common/languages/nullTokenize.js +1 -1
- package/vscode/src/vs/editor/common/standaloneStrings.js +17 -1
- package/vscode/src/vs/platform/actions/browser/toolbar.d.ts +73 -0
- package/vscode/src/vs/platform/files/browser/htmlFileSystemProvider.d.ts +43 -0
- package/vscode/src/vs/platform/files/browser/indexedDBFileSystemProvider.d.ts +48 -0
- package/vscode/src/vs/platform/files/common/inMemoryFilesystemProvider.d.ts +59 -0
- package/vscode/src/vs/platform/remote/common/remoteExtensionsScanner.service.d.ts +13 -0
- package/vscode/src/vs/workbench/browser/dnd.d.ts +14 -0
- package/vscode/src/vs/workbench/browser/parts/activitybar/activitybarPart.d.ts +61 -0
- package/vscode/src/vs/workbench/browser/parts/banner/bannerPart.d.ts +46 -0
- package/vscode/src/vs/workbench/browser/parts/compositeBarActions.d.ts +21 -0
- package/vscode/src/vs/workbench/browser/parts/compositePart.d.ts +89 -0
- package/vscode/src/vs/workbench/browser/parts/paneCompositeBar.d.ts +108 -0
- package/vscode/src/vs/workbench/browser/parts/paneCompositePart.d.ts +138 -0
- package/vscode/src/vs/workbench/browser/parts/panel/panelPart.d.ts +35 -0
- package/vscode/src/vs/workbench/browser/parts/sidebar/sidebarPart.d.ts +48 -0
- package/vscode/src/vs/workbench/browser/workbench.d.ts +10 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminal.d.ts +795 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminal.service.d.ts +149 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalConfigHelper.d.ts +48 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalStatusList.d.ts +25 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/markNavigationAddon.d.ts +8 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.d.ts +168 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm-private.d.ts +55 -0
- package/vscode/src/vs/workbench/contrib/terminal/common/environmentVariable.d.ts +9 -0
- package/vscode/src/vs/workbench/contrib/terminal/common/terminal.d.ts +238 -0
- package/vscode/src/vs/workbench/services/activity/browser/activityService.d.ts +28 -0
- package/vscode/src/vs/workbench/services/extensionManagement/common/extensionManagement.d.ts +53 -0
- package/vscode/src/vs/workbench/services/extensionManagement/common/extensionManagement.service.d.ts +106 -0
- package/vscode/src/vs/workbench/services/extensions/browser/extensionService.d.ts +45 -0
- package/vscode/src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.d.ts +11 -0
- package/vscode/src/vs/workbench/services/extensions/common/abstractExtensionService.d.ts +162 -0
- package/vscode/src/vs/workbench/services/extensions/common/extensionDescriptionRegistry.d.ts +18 -0
- package/vscode/src/vs/workbench/services/extensions/common/extensionHostManagers.d.ts +39 -0
- package/vscode/src/vs/workbench/services/extensions/common/extensionHostProxy.d.ts +17 -0
- package/vscode/src/vs/workbench/services/extensions/common/extensionManifestPropertiesService.service.d.ts +20 -0
- package/vscode/src/vs/workbench/services/extensions/common/extensionRunningLocationTracker.d.ts +45 -0
- package/vscode/src/vs/workbench/services/extensions/common/extensionsProposedApi.d.ts +17 -0
- package/vscode/src/vs/workbench/services/extensions/common/rpcProtocol.d.ts +6 -0
- package/vscode/src/vs/workbench/services/remote/common/remoteExplorerService.d.ts +50 -0
- package/vscode/src/vs/workbench/services/remote/common/remoteExplorerService.service.d.ts +40 -0
- package/vscode/src/vs/workbench/services/remote/common/tunnelModel.d.ts +185 -0
- package/vscode/src/vs/workbench/services/storage/browser/storageService.d.ts +41 -0
- package/vscode/src/vs/workbench/services/textMate/browser/textMateTokenizationFeature.service.d.ts +11 -0
- package/vscode/src/vs/workbench/services/userData/browser/userDataInit.d.ts +11 -0
- package/vscode/src/vs/workbench/services/userData/browser/userDataInit.service.d.ts +9 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/inspectEditorTokens/inspectEditorTokens.css.js +0 -4
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/inspectEditorTokens/inspectEditorTokens.js +0 -503
- package/vscode/src/vs/workbench/services/textMate/common/TMHelper.js +0 -107
|
@@ -1,503 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from '../../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import './inspectEditorTokens.css.js';
|
|
3
|
-
import { localizeWithPath } from '../../../../../nls.js';
|
|
4
|
-
import { clearNode, reset, append, $ as $$1 } from '../../../../../base/browser/dom.js';
|
|
5
|
-
import { Color } from '../../../../../base/common/color.js';
|
|
6
|
-
import { Disposable } from '../../../../../base/common/lifecycle.js';
|
|
7
|
-
import { registerEditorContribution, registerEditorAction, EditorAction } from '../../../../../editor/browser/editorExtensions.js';
|
|
8
|
-
import { Range } from '../../../../../editor/common/core/range.js';
|
|
9
|
-
import { TokenMetadata } from '../../../../../editor/common/encodedTokenAttributes.js';
|
|
10
|
-
import { ILanguageService } from '../../../../../editor/common/languages/language.js';
|
|
11
|
-
import { INotificationService } from '../../../../../platform/notification/common/notification.service.js';
|
|
12
|
-
import { findMatchingThemeRule } from '../../../../services/textMate/common/TMHelper.js';
|
|
13
|
-
import { ITextMateTokenizationService } from '../../../../services/textMate/browser/textMateTokenizationFeature.service.js';
|
|
14
|
-
import { IWorkbenchThemeService } from '../../../../services/themes/common/workbenchThemeService.service.js';
|
|
15
|
-
import { CancellationTokenSource } from '../../../../../base/common/cancellation.js';
|
|
16
|
-
import { SemanticTokenRule } from '../../../../../platform/theme/common/tokenClassificationRegistry.js';
|
|
17
|
-
import { IConfigurationService } from '../../../../../platform/configuration/common/configuration.service.js';
|
|
18
|
-
import { SEMANTIC_HIGHLIGHTING_SETTING_ID } from '../../../../../editor/contrib/semanticTokens/common/semanticTokensConfig.js';
|
|
19
|
-
import { Schemas } from '../../../../../base/common/network.js';
|
|
20
|
-
import { ILanguageFeaturesService } from '../../../../../editor/common/services/languageFeatures.js';
|
|
21
|
-
var InspectEditorTokensController_1;
|
|
22
|
-
const $ = $$1;
|
|
23
|
-
let InspectEditorTokensController = class InspectEditorTokensController extends Disposable {
|
|
24
|
-
static { InspectEditorTokensController_1 = this; }
|
|
25
|
-
static { this.ID = 'editor.contrib.inspectEditorTokens'; }
|
|
26
|
-
static get(editor) {
|
|
27
|
-
return editor.getContribution(InspectEditorTokensController_1.ID);
|
|
28
|
-
}
|
|
29
|
-
constructor(editor, textMateService, languageService, themeService, notificationService, configurationService, languageFeaturesService) {
|
|
30
|
-
super();
|
|
31
|
-
this._editor = editor;
|
|
32
|
-
this._textMateService = textMateService;
|
|
33
|
-
this._themeService = themeService;
|
|
34
|
-
this._languageService = languageService;
|
|
35
|
-
this._notificationService = notificationService;
|
|
36
|
-
this._configurationService = configurationService;
|
|
37
|
-
this._languageFeaturesService = languageFeaturesService;
|
|
38
|
-
this._widget = null;
|
|
39
|
-
this._register(this._editor.onDidChangeModel((e) => this.stop()));
|
|
40
|
-
this._register(this._editor.onDidChangeModelLanguage((e) => this.stop()));
|
|
41
|
-
this._register(this._editor.onKeyUp((e) => e.keyCode === 9 && this.stop()));
|
|
42
|
-
}
|
|
43
|
-
dispose() {
|
|
44
|
-
this.stop();
|
|
45
|
-
super.dispose();
|
|
46
|
-
}
|
|
47
|
-
launch() {
|
|
48
|
-
if (this._widget) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
if (!this._editor.hasModel()) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
if (this._editor.getModel().uri.scheme === Schemas.vscodeNotebookCell) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
this._widget = ( new InspectEditorTokensWidget(
|
|
58
|
-
this._editor,
|
|
59
|
-
this._textMateService,
|
|
60
|
-
this._languageService,
|
|
61
|
-
this._themeService,
|
|
62
|
-
this._notificationService,
|
|
63
|
-
this._configurationService,
|
|
64
|
-
this._languageFeaturesService
|
|
65
|
-
));
|
|
66
|
-
}
|
|
67
|
-
stop() {
|
|
68
|
-
if (this._widget) {
|
|
69
|
-
this._widget.dispose();
|
|
70
|
-
this._widget = null;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
toggle() {
|
|
74
|
-
if (!this._widget) {
|
|
75
|
-
this.launch();
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
this.stop();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
InspectEditorTokensController = InspectEditorTokensController_1 = ( __decorate([
|
|
83
|
-
( __param(1, ITextMateTokenizationService)),
|
|
84
|
-
( __param(2, ILanguageService)),
|
|
85
|
-
( __param(3, IWorkbenchThemeService)),
|
|
86
|
-
( __param(4, INotificationService)),
|
|
87
|
-
( __param(5, IConfigurationService)),
|
|
88
|
-
( __param(6, ILanguageFeaturesService))
|
|
89
|
-
], InspectEditorTokensController));
|
|
90
|
-
class InspectEditorTokens extends EditorAction {
|
|
91
|
-
constructor() {
|
|
92
|
-
super({
|
|
93
|
-
id: 'editor.action.inspectTMScopes',
|
|
94
|
-
label: ( localizeWithPath(
|
|
95
|
-
'vs/workbench/contrib/codeEditor/browser/inspectEditorTokens/inspectEditorTokens',
|
|
96
|
-
'inspectEditorTokens',
|
|
97
|
-
"Developer: Inspect Editor Tokens and Scopes"
|
|
98
|
-
)),
|
|
99
|
-
alias: 'Developer: Inspect Editor Tokens and Scopes',
|
|
100
|
-
precondition: undefined
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
run(accessor, editor) {
|
|
104
|
-
const controller = InspectEditorTokensController.get(editor);
|
|
105
|
-
controller?.toggle();
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
function renderTokenText(tokenText) {
|
|
109
|
-
if (tokenText.length > 40) {
|
|
110
|
-
tokenText = tokenText.substr(0, 20) + '…' + tokenText.substr(tokenText.length - 20);
|
|
111
|
-
}
|
|
112
|
-
let result = '';
|
|
113
|
-
for (let charIndex = 0, len = tokenText.length; charIndex < len; charIndex++) {
|
|
114
|
-
const charCode = tokenText.charCodeAt(charIndex);
|
|
115
|
-
switch (charCode) {
|
|
116
|
-
case 9 :
|
|
117
|
-
result += '\u2192';
|
|
118
|
-
break;
|
|
119
|
-
case 32 :
|
|
120
|
-
result += '\u00B7';
|
|
121
|
-
break;
|
|
122
|
-
default:
|
|
123
|
-
result += String.fromCharCode(charCode);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return result;
|
|
127
|
-
}
|
|
128
|
-
class InspectEditorTokensWidget extends Disposable {
|
|
129
|
-
static { this._ID = 'editor.contrib.inspectEditorTokensWidget'; }
|
|
130
|
-
constructor(editor, textMateService, languageService, themeService, notificationService, configurationService, languageFeaturesService) {
|
|
131
|
-
super();
|
|
132
|
-
this.allowEditorOverflow = true;
|
|
133
|
-
this._isDisposed = false;
|
|
134
|
-
this._editor = editor;
|
|
135
|
-
this._languageService = languageService;
|
|
136
|
-
this._themeService = themeService;
|
|
137
|
-
this._textMateService = textMateService;
|
|
138
|
-
this._notificationService = notificationService;
|
|
139
|
-
this._configurationService = configurationService;
|
|
140
|
-
this._languageFeaturesService = languageFeaturesService;
|
|
141
|
-
this._model = this._editor.getModel();
|
|
142
|
-
this._domNode = document.createElement('div');
|
|
143
|
-
this._domNode.className = 'token-inspect-widget';
|
|
144
|
-
this._currentRequestCancellationTokenSource = ( new CancellationTokenSource());
|
|
145
|
-
this._beginCompute(this._editor.getPosition());
|
|
146
|
-
this._register(this._editor.onDidChangeCursorPosition((e) => this._beginCompute(this._editor.getPosition())));
|
|
147
|
-
this._register(themeService.onDidColorThemeChange(_ => this._beginCompute(this._editor.getPosition())));
|
|
148
|
-
this._register(configurationService.onDidChangeConfiguration(e => e.affectsConfiguration('editor.semanticHighlighting.enabled') && this._beginCompute(this._editor.getPosition())));
|
|
149
|
-
this._editor.addContentWidget(this);
|
|
150
|
-
}
|
|
151
|
-
dispose() {
|
|
152
|
-
this._isDisposed = true;
|
|
153
|
-
this._editor.removeContentWidget(this);
|
|
154
|
-
this._currentRequestCancellationTokenSource.cancel();
|
|
155
|
-
super.dispose();
|
|
156
|
-
}
|
|
157
|
-
getId() {
|
|
158
|
-
return InspectEditorTokensWidget._ID;
|
|
159
|
-
}
|
|
160
|
-
_beginCompute(position) {
|
|
161
|
-
const grammar = this._textMateService.createTokenizer(this._model.getLanguageId());
|
|
162
|
-
const semanticTokens = this._computeSemanticTokens(position);
|
|
163
|
-
clearNode(this._domNode);
|
|
164
|
-
this._domNode.appendChild(document.createTextNode(( localizeWithPath(
|
|
165
|
-
'vs/workbench/contrib/codeEditor/browser/inspectEditorTokens/inspectEditorTokens',
|
|
166
|
-
'inspectTMScopesWidget.loading',
|
|
167
|
-
"Loading..."
|
|
168
|
-
))));
|
|
169
|
-
Promise.all([grammar, semanticTokens]).then(([grammar, semanticTokens]) => {
|
|
170
|
-
if (this._isDisposed) {
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
this._compute(grammar, semanticTokens, position);
|
|
174
|
-
this._domNode.style.maxWidth = `${Math.max(this._editor.getLayoutInfo().width * 0.66, 500)}px`;
|
|
175
|
-
this._editor.layoutContentWidget(this);
|
|
176
|
-
}, (err) => {
|
|
177
|
-
this._notificationService.warn(err);
|
|
178
|
-
setTimeout(() => {
|
|
179
|
-
InspectEditorTokensController.get(this._editor)?.stop();
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
_isSemanticColoringEnabled() {
|
|
184
|
-
const setting = this._configurationService.getValue(SEMANTIC_HIGHLIGHTING_SETTING_ID, { overrideIdentifier: this._model.getLanguageId(), resource: this._model.uri })?.enabled;
|
|
185
|
-
if (typeof setting === 'boolean') {
|
|
186
|
-
return setting;
|
|
187
|
-
}
|
|
188
|
-
return this._themeService.getColorTheme().semanticHighlighting;
|
|
189
|
-
}
|
|
190
|
-
_compute(grammar, semanticTokens, position) {
|
|
191
|
-
const textMateTokenInfo = grammar && this._getTokensAtPosition(grammar, position);
|
|
192
|
-
const semanticTokenInfo = semanticTokens && this._getSemanticTokenAtPosition(semanticTokens, position);
|
|
193
|
-
if (!textMateTokenInfo && !semanticTokenInfo) {
|
|
194
|
-
reset(this._domNode, 'No grammar or semantic tokens available.');
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
const tmMetadata = textMateTokenInfo?.metadata;
|
|
198
|
-
const semMetadata = semanticTokenInfo?.metadata;
|
|
199
|
-
const semTokenText = semanticTokenInfo && renderTokenText(this._model.getValueInRange(semanticTokenInfo.range));
|
|
200
|
-
const tmTokenText = textMateTokenInfo && renderTokenText(this._model.getLineContent(position.lineNumber).substring(textMateTokenInfo.token.startIndex, textMateTokenInfo.token.endIndex));
|
|
201
|
-
const tokenText = semTokenText || tmTokenText || '';
|
|
202
|
-
reset(this._domNode, $('h2.tiw-token', undefined, tokenText, $('span.tiw-token-length', undefined, `${tokenText.length} ${tokenText.length === 1 ? 'char' : 'chars'}`)));
|
|
203
|
-
append(this._domNode, $('hr.tiw-metadata-separator', { 'style': 'clear:both' }));
|
|
204
|
-
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 || 0 ))), ...this._formatMetadata(semMetadata, tmMetadata))));
|
|
205
|
-
if (semanticTokenInfo) {
|
|
206
|
-
append(this._domNode, $('hr.tiw-metadata-separator'));
|
|
207
|
-
const table = append(this._domNode, $('table.tiw-metadata-table', undefined));
|
|
208
|
-
const tbody = append(table, $('tbody', undefined, $('tr', undefined, $('td.tiw-metadata-key', undefined, 'semantic token type'), $('td.tiw-metadata-value', undefined, semanticTokenInfo.type))));
|
|
209
|
-
if (semanticTokenInfo.modifiers.length) {
|
|
210
|
-
append(tbody, $('tr', undefined, $('td.tiw-metadata-key', undefined, 'modifiers'), $('td.tiw-metadata-value', undefined, semanticTokenInfo.modifiers.join(' '))));
|
|
211
|
-
}
|
|
212
|
-
if (semanticTokenInfo.metadata) {
|
|
213
|
-
const properties = ['foreground', 'bold', 'italic', 'underline', 'strikethrough'];
|
|
214
|
-
const propertiesByDefValue = {};
|
|
215
|
-
const allDefValues = ( new Array());
|
|
216
|
-
for (const property of properties) {
|
|
217
|
-
if (semanticTokenInfo.metadata[property] !== undefined) {
|
|
218
|
-
const definition = semanticTokenInfo.definitions[property];
|
|
219
|
-
const defValue = this._renderTokenStyleDefinition(definition, property);
|
|
220
|
-
const defValueStr = ( defValue.map(el => el instanceof HTMLElement ? el.outerHTML : el)).join();
|
|
221
|
-
let properties = propertiesByDefValue[defValueStr];
|
|
222
|
-
if (!properties) {
|
|
223
|
-
propertiesByDefValue[defValueStr] = properties = [];
|
|
224
|
-
allDefValues.push([defValue, defValueStr]);
|
|
225
|
-
}
|
|
226
|
-
properties.push(property);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
for (const [defValue, defValueStr] of allDefValues) {
|
|
230
|
-
append(tbody, $('tr', undefined, $('td.tiw-metadata-key', undefined, propertiesByDefValue[defValueStr].join(', ')), $('td.tiw-metadata-value', undefined, ...defValue)));
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
if (textMateTokenInfo) {
|
|
235
|
-
const theme = this._themeService.getColorTheme();
|
|
236
|
-
append(this._domNode, $('hr.tiw-metadata-separator'));
|
|
237
|
-
const table = append(this._domNode, $('table.tiw-metadata-table'));
|
|
238
|
-
const tbody = append(table, $('tbody'));
|
|
239
|
-
if (tmTokenText && tmTokenText !== tokenText) {
|
|
240
|
-
append(tbody, $('tr', undefined, $('td.tiw-metadata-key', undefined, 'textmate token'), $('td.tiw-metadata-value', undefined, `${tmTokenText} (${tmTokenText.length})`)));
|
|
241
|
-
}
|
|
242
|
-
const scopes = ( new Array());
|
|
243
|
-
for (let i = textMateTokenInfo.token.scopes.length - 1; i >= 0; i--) {
|
|
244
|
-
scopes.push(textMateTokenInfo.token.scopes[i]);
|
|
245
|
-
if (i > 0) {
|
|
246
|
-
scopes.push($('br'));
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
append(tbody, $('tr', undefined, $('td.tiw-metadata-key', undefined, 'textmate scopes'), $('td.tiw-metadata-value.tiw-metadata-scopes', undefined, ...scopes)));
|
|
250
|
-
const matchingRule = findMatchingThemeRule(theme, textMateTokenInfo.token.scopes, false);
|
|
251
|
-
const semForeground = semanticTokenInfo?.metadata?.foreground;
|
|
252
|
-
if (matchingRule) {
|
|
253
|
-
if (semForeground !== textMateTokenInfo.metadata.foreground) {
|
|
254
|
-
let defValue = $('code.tiw-theme-selector', undefined, matchingRule.rawSelector, $('br'), JSON.stringify(matchingRule.settings, null, '\t'));
|
|
255
|
-
if (semForeground) {
|
|
256
|
-
defValue = $('s', undefined, defValue);
|
|
257
|
-
}
|
|
258
|
-
append(tbody, $('tr', undefined, $('td.tiw-metadata-key', undefined, 'foreground'), $('td.tiw-metadata-value', undefined, defValue)));
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
else if (!semForeground) {
|
|
262
|
-
append(tbody, $('tr', undefined, $('td.tiw-metadata-key', undefined, 'foreground'), $('td.tiw-metadata-value', undefined, 'No theme selector')));
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
_formatMetadata(semantic, tm) {
|
|
267
|
-
const elements = ( new Array());
|
|
268
|
-
function render(property) {
|
|
269
|
-
const value = semantic?.[property] || tm?.[property];
|
|
270
|
-
if (value !== undefined) {
|
|
271
|
-
const semanticStyle = semantic?.[property] ? 'tiw-metadata-semantic' : '';
|
|
272
|
-
elements.push($('tr', undefined, $('td.tiw-metadata-key', undefined, property), $(`td.tiw-metadata-value.${semanticStyle}`, undefined, value)));
|
|
273
|
-
}
|
|
274
|
-
return value;
|
|
275
|
-
}
|
|
276
|
-
const foreground = render('foreground');
|
|
277
|
-
const background = render('background');
|
|
278
|
-
if (foreground && background) {
|
|
279
|
-
const backgroundColor = ( Color.fromHex(background)), foregroundColor = ( Color.fromHex(foreground));
|
|
280
|
-
if (backgroundColor.isOpaque()) {
|
|
281
|
-
elements.push($('tr', undefined, $('td.tiw-metadata-key', undefined, 'contrast ratio'), $('td.tiw-metadata-value', undefined, backgroundColor.getContrastRatio(foregroundColor.makeOpaque(backgroundColor)).toFixed(2))));
|
|
282
|
-
}
|
|
283
|
-
else {
|
|
284
|
-
elements.push($('tr', undefined, $('td.tiw-metadata-key', undefined, 'Contrast ratio cannot be precise for background colors that use transparency'), $('td.tiw-metadata-value')));
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
const fontStyleLabels = ( new Array());
|
|
288
|
-
function addStyle(key) {
|
|
289
|
-
let label;
|
|
290
|
-
if (semantic && semantic[key]) {
|
|
291
|
-
label = $('span.tiw-metadata-semantic', undefined, key);
|
|
292
|
-
}
|
|
293
|
-
else if (tm && tm[key]) {
|
|
294
|
-
label = key;
|
|
295
|
-
}
|
|
296
|
-
if (label) {
|
|
297
|
-
if (fontStyleLabels.length) {
|
|
298
|
-
fontStyleLabels.push(' ');
|
|
299
|
-
}
|
|
300
|
-
fontStyleLabels.push(label);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
addStyle('bold');
|
|
304
|
-
addStyle('italic');
|
|
305
|
-
addStyle('underline');
|
|
306
|
-
addStyle('strikethrough');
|
|
307
|
-
if (fontStyleLabels.length) {
|
|
308
|
-
elements.push($('tr', undefined, $('td.tiw-metadata-key', undefined, 'font style'), $('td.tiw-metadata-value', undefined, ...fontStyleLabels)));
|
|
309
|
-
}
|
|
310
|
-
return elements;
|
|
311
|
-
}
|
|
312
|
-
_decodeMetadata(metadata) {
|
|
313
|
-
const colorMap = this._themeService.getColorTheme().tokenColorMap;
|
|
314
|
-
const languageId = TokenMetadata.getLanguageId(metadata);
|
|
315
|
-
const tokenType = TokenMetadata.getTokenType(metadata);
|
|
316
|
-
const fontStyle = TokenMetadata.getFontStyle(metadata);
|
|
317
|
-
const foreground = TokenMetadata.getForeground(metadata);
|
|
318
|
-
const background = TokenMetadata.getBackground(metadata);
|
|
319
|
-
return {
|
|
320
|
-
languageId: this._languageService.languageIdCodec.decodeLanguageId(languageId),
|
|
321
|
-
tokenType: tokenType,
|
|
322
|
-
bold: ((fontStyle & 2) ) ? true : undefined,
|
|
323
|
-
italic: ((fontStyle & 1) ) ? true : undefined,
|
|
324
|
-
underline: ((fontStyle & 4) ) ? true : undefined,
|
|
325
|
-
strikethrough: ((fontStyle & 8) ) ? true : undefined,
|
|
326
|
-
foreground: colorMap[foreground],
|
|
327
|
-
background: colorMap[background]
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
_tokenTypeToString(tokenType) {
|
|
331
|
-
switch (tokenType) {
|
|
332
|
-
case 0 : return 'Other';
|
|
333
|
-
case 1 : return 'Comment';
|
|
334
|
-
case 2 : return 'String';
|
|
335
|
-
case 3 : return 'RegEx';
|
|
336
|
-
default: return '??';
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
_getTokensAtPosition(grammar, position) {
|
|
340
|
-
const lineNumber = position.lineNumber;
|
|
341
|
-
const stateBeforeLine = this._getStateBeforeLine(grammar, lineNumber);
|
|
342
|
-
const tokenizationResult1 = grammar.tokenizeLine(this._model.getLineContent(lineNumber), stateBeforeLine);
|
|
343
|
-
const tokenizationResult2 = grammar.tokenizeLine2(this._model.getLineContent(lineNumber), stateBeforeLine);
|
|
344
|
-
let token1Index = 0;
|
|
345
|
-
for (let i = tokenizationResult1.tokens.length - 1; i >= 0; i--) {
|
|
346
|
-
const t = tokenizationResult1.tokens[i];
|
|
347
|
-
if (position.column - 1 >= t.startIndex) {
|
|
348
|
-
token1Index = i;
|
|
349
|
-
break;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
let token2Index = 0;
|
|
353
|
-
for (let i = (tokenizationResult2.tokens.length >>> 1); i >= 0; i--) {
|
|
354
|
-
if (position.column - 1 >= tokenizationResult2.tokens[(i << 1)]) {
|
|
355
|
-
token2Index = i;
|
|
356
|
-
break;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
return {
|
|
360
|
-
token: tokenizationResult1.tokens[token1Index],
|
|
361
|
-
metadata: this._decodeMetadata(tokenizationResult2.tokens[(token2Index << 1) + 1])
|
|
362
|
-
};
|
|
363
|
-
}
|
|
364
|
-
_getStateBeforeLine(grammar, lineNumber) {
|
|
365
|
-
let state = null;
|
|
366
|
-
for (let i = 1; i < lineNumber; i++) {
|
|
367
|
-
const tokenizationResult = grammar.tokenizeLine(this._model.getLineContent(i), state);
|
|
368
|
-
state = tokenizationResult.ruleStack;
|
|
369
|
-
}
|
|
370
|
-
return state;
|
|
371
|
-
}
|
|
372
|
-
isSemanticTokens(token) {
|
|
373
|
-
return token && token.data;
|
|
374
|
-
}
|
|
375
|
-
async _computeSemanticTokens(position) {
|
|
376
|
-
if (!this._isSemanticColoringEnabled()) {
|
|
377
|
-
return null;
|
|
378
|
-
}
|
|
379
|
-
const tokenProviders = this._languageFeaturesService.documentSemanticTokensProvider.ordered(this._model);
|
|
380
|
-
if (tokenProviders.length) {
|
|
381
|
-
const provider = tokenProviders[0];
|
|
382
|
-
const tokens = await Promise.resolve(provider.provideDocumentSemanticTokens(this._model, null, this._currentRequestCancellationTokenSource.token));
|
|
383
|
-
if (this.isSemanticTokens(tokens)) {
|
|
384
|
-
return { tokens, legend: provider.getLegend() };
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
const rangeTokenProviders = this._languageFeaturesService.documentRangeSemanticTokensProvider.ordered(this._model);
|
|
388
|
-
if (rangeTokenProviders.length) {
|
|
389
|
-
const provider = rangeTokenProviders[0];
|
|
390
|
-
const lineNumber = position.lineNumber;
|
|
391
|
-
const range = ( new Range(lineNumber, 1, lineNumber, this._model.getLineMaxColumn(lineNumber)));
|
|
392
|
-
const tokens = await Promise.resolve(provider.provideDocumentRangeSemanticTokens(this._model, range, this._currentRequestCancellationTokenSource.token));
|
|
393
|
-
if (this.isSemanticTokens(tokens)) {
|
|
394
|
-
return { tokens, legend: provider.getLegend() };
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
return null;
|
|
398
|
-
}
|
|
399
|
-
_getSemanticTokenAtPosition(semanticTokens, pos) {
|
|
400
|
-
const tokenData = semanticTokens.tokens.data;
|
|
401
|
-
const defaultLanguage = this._model.getLanguageId();
|
|
402
|
-
let lastLine = 0;
|
|
403
|
-
let lastCharacter = 0;
|
|
404
|
-
const posLine = pos.lineNumber - 1, posCharacter = pos.column - 1;
|
|
405
|
-
for (let i = 0; i < tokenData.length; i += 5) {
|
|
406
|
-
const lineDelta = tokenData[i], charDelta = tokenData[i + 1], len = tokenData[i + 2], typeIdx = tokenData[i + 3], modSet = tokenData[i + 4];
|
|
407
|
-
const line = lastLine + lineDelta;
|
|
408
|
-
const character = lineDelta === 0 ? lastCharacter + charDelta : charDelta;
|
|
409
|
-
if (posLine === line && character <= posCharacter && posCharacter < character + len) {
|
|
410
|
-
const type = semanticTokens.legend.tokenTypes[typeIdx] || 'not in legend (ignored)';
|
|
411
|
-
const modifiers = [];
|
|
412
|
-
let modifierSet = modSet;
|
|
413
|
-
for (let modifierIndex = 0; modifierSet > 0 && modifierIndex < semanticTokens.legend.tokenModifiers.length; modifierIndex++) {
|
|
414
|
-
if (modifierSet & 1) {
|
|
415
|
-
modifiers.push(semanticTokens.legend.tokenModifiers[modifierIndex]);
|
|
416
|
-
}
|
|
417
|
-
modifierSet = modifierSet >> 1;
|
|
418
|
-
}
|
|
419
|
-
if (modifierSet > 0) {
|
|
420
|
-
modifiers.push('not in legend (ignored)');
|
|
421
|
-
}
|
|
422
|
-
const range = ( new Range(line + 1, character + 1, line + 1, character + 1 + len));
|
|
423
|
-
const definitions = {};
|
|
424
|
-
const colorMap = this._themeService.getColorTheme().tokenColorMap;
|
|
425
|
-
const theme = this._themeService.getColorTheme();
|
|
426
|
-
const tokenStyle = theme.getTokenStyleMetadata(type, modifiers, defaultLanguage, true, definitions);
|
|
427
|
-
let metadata = undefined;
|
|
428
|
-
if (tokenStyle) {
|
|
429
|
-
metadata = {
|
|
430
|
-
languageId: undefined,
|
|
431
|
-
tokenType: 0 ,
|
|
432
|
-
bold: tokenStyle?.bold,
|
|
433
|
-
italic: tokenStyle?.italic,
|
|
434
|
-
underline: tokenStyle?.underline,
|
|
435
|
-
strikethrough: tokenStyle?.strikethrough,
|
|
436
|
-
foreground: colorMap[tokenStyle?.foreground || 0 ],
|
|
437
|
-
background: undefined
|
|
438
|
-
};
|
|
439
|
-
}
|
|
440
|
-
return { type, modifiers, range, metadata, definitions };
|
|
441
|
-
}
|
|
442
|
-
lastLine = line;
|
|
443
|
-
lastCharacter = character;
|
|
444
|
-
}
|
|
445
|
-
return null;
|
|
446
|
-
}
|
|
447
|
-
_renderTokenStyleDefinition(definition, property) {
|
|
448
|
-
const elements = ( new Array());
|
|
449
|
-
if (definition === undefined) {
|
|
450
|
-
return elements;
|
|
451
|
-
}
|
|
452
|
-
const theme = this._themeService.getColorTheme();
|
|
453
|
-
if (Array.isArray(definition)) {
|
|
454
|
-
const scopesDefinition = {};
|
|
455
|
-
theme.resolveScopes(definition, scopesDefinition);
|
|
456
|
-
const matchingRule = scopesDefinition[property];
|
|
457
|
-
if (matchingRule && scopesDefinition.scope) {
|
|
458
|
-
const scopes = $('ul.tiw-metadata-values');
|
|
459
|
-
const strScopes = Array.isArray(matchingRule.scope) ? matchingRule.scope : [String(matchingRule.scope)];
|
|
460
|
-
for (const strScope of strScopes) {
|
|
461
|
-
scopes.appendChild($('li.tiw-metadata-value.tiw-metadata-scopes', undefined, strScope));
|
|
462
|
-
}
|
|
463
|
-
elements.push(scopesDefinition.scope.join(' '), scopes, $('code.tiw-theme-selector', undefined, JSON.stringify(matchingRule.settings, null, '\t')));
|
|
464
|
-
return elements;
|
|
465
|
-
}
|
|
466
|
-
return elements;
|
|
467
|
-
}
|
|
468
|
-
else if (SemanticTokenRule.is(definition)) {
|
|
469
|
-
const scope = theme.getTokenStylingRuleScope(definition);
|
|
470
|
-
if (scope === 'setting') {
|
|
471
|
-
elements.push(`User settings: ${definition.selector.id} - ${this._renderStyleProperty(definition.style, property)}`);
|
|
472
|
-
return elements;
|
|
473
|
-
}
|
|
474
|
-
else if (scope === 'theme') {
|
|
475
|
-
elements.push(`Color theme: ${definition.selector.id} - ${this._renderStyleProperty(definition.style, property)}`);
|
|
476
|
-
return elements;
|
|
477
|
-
}
|
|
478
|
-
return elements;
|
|
479
|
-
}
|
|
480
|
-
else {
|
|
481
|
-
const style = theme.resolveTokenStyleValue(definition);
|
|
482
|
-
elements.push(`Default: ${style ? this._renderStyleProperty(style, property) : ''}`);
|
|
483
|
-
return elements;
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
_renderStyleProperty(style, property) {
|
|
487
|
-
switch (property) {
|
|
488
|
-
case 'foreground': return style.foreground ? Color.Format.CSS.formatHexA(style.foreground, true) : '';
|
|
489
|
-
default: return style[property] !== undefined ? String(style[property]) : '';
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
getDomNode() {
|
|
493
|
-
return this._domNode;
|
|
494
|
-
}
|
|
495
|
-
getPosition() {
|
|
496
|
-
return {
|
|
497
|
-
position: this._editor.getPosition(),
|
|
498
|
-
preference: [2 , 1 ]
|
|
499
|
-
};
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
registerEditorContribution(InspectEditorTokensController.ID, InspectEditorTokensController, 4 );
|
|
503
|
-
registerEditorAction(InspectEditorTokens);
|
|
@@ -1,107 +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
|
-
export { ThemeRule, findMatchingThemeRule };
|