@codingame/monaco-vscode-editor-api 25.1.2 → 26.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/vscode/src/vs/editor/editor.api.d.ts +27 -2
- package/vscode/src/vs/editor/standalone/browser/colorizer.js +26 -20
- package/vscode/src/vs/editor/standalone/browser/standaloneEditor.js +46 -23
- package/vscode/src/vs/editor/standalone/browser/standaloneLanguages.js +32 -30
- package/vscode/src/vs/editor/standalone/browser/standaloneWebWorker.js +6 -7
- package/vscode/src/vs/editor/standalone/common/monarch/monarchCommon.js +15 -17
- package/vscode/src/vs/editor/standalone/common/monarch/monarchCompile.js +232 -167
- package/vscode/src/vs/editor/standalone/common/monarch/monarchLexer.js +148 -109
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-editor-api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "26.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "VSCode public API plugged on the monaco editor - monaco-editor compatible api",
|
|
6
6
|
"keywords": [],
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@codingame/monaco-vscode-api": "
|
|
18
|
+
"@codingame/monaco-vscode-api": "26.0.0"
|
|
19
19
|
},
|
|
20
20
|
"exports": {
|
|
21
21
|
".": "./esm/vs/editor/editor.api.js",
|
|
@@ -1654,7 +1654,7 @@ export namespace editor {
|
|
|
1654
1654
|
*/
|
|
1655
1655
|
glyphMargin?: IModelDecorationGlyphMarginOptions | null;
|
|
1656
1656
|
/**
|
|
1657
|
-
* If set, the decoration will override the line height of the lines it spans.
|
|
1657
|
+
* If set, the decoration will override the line height of the lines it spans. This value is a multiplier to the default line height.
|
|
1658
1658
|
*/
|
|
1659
1659
|
lineHeight?: number | null;
|
|
1660
1660
|
/**
|
|
@@ -6150,6 +6150,10 @@ export namespace editor {
|
|
|
6150
6150
|
* Force an editor render now.
|
|
6151
6151
|
*/
|
|
6152
6152
|
render(forceRedraw?: boolean): void;
|
|
6153
|
+
/**
|
|
6154
|
+
* Render the editor at the next animation frame.
|
|
6155
|
+
*/
|
|
6156
|
+
renderAsync(forceRedraw?: boolean): void;
|
|
6153
6157
|
/**
|
|
6154
6158
|
* Get the hit test target at coordinates `clientX` and `clientY`.
|
|
6155
6159
|
* The coordinates are relative to the top-left of the viewport.
|
|
@@ -7166,6 +7170,17 @@ export namespace languages {
|
|
|
7166
7170
|
*/
|
|
7167
7171
|
Explicit = 1
|
|
7168
7172
|
}
|
|
7173
|
+
/**
|
|
7174
|
+
* Arbitrary data that the provider can pass when firing {@link InlineCompletionsProvider.onDidChangeInlineCompletions}.
|
|
7175
|
+
* This data is passed back to the provider in {@link InlineCompletionContext.changeHint}.
|
|
7176
|
+
*/
|
|
7177
|
+
export interface IInlineCompletionChangeHint {
|
|
7178
|
+
/**
|
|
7179
|
+
* Arbitrary data that the provider can use to identify what triggered the change.
|
|
7180
|
+
* This data must be JSON serializable.
|
|
7181
|
+
*/
|
|
7182
|
+
readonly data?: unknown;
|
|
7183
|
+
}
|
|
7169
7184
|
export interface InlineCompletionContext {
|
|
7170
7185
|
/**
|
|
7171
7186
|
* How the completion was triggered.
|
|
@@ -7176,6 +7191,11 @@ export namespace languages {
|
|
|
7176
7191
|
readonly includeInlineCompletions: boolean;
|
|
7177
7192
|
readonly requestIssuedDateTime: number;
|
|
7178
7193
|
readonly earliestShownDateTime: number;
|
|
7194
|
+
/**
|
|
7195
|
+
* The change hint that was passed to {@link InlineCompletionsProvider.onDidChangeInlineCompletions}.
|
|
7196
|
+
* Only set if this request was triggered by such an event.
|
|
7197
|
+
*/
|
|
7198
|
+
readonly changeHint?: IInlineCompletionChangeHint;
|
|
7179
7199
|
}
|
|
7180
7200
|
export interface IInlineCompletionModelInfo {
|
|
7181
7201
|
models: IInlineCompletionModel[];
|
|
@@ -7308,7 +7328,12 @@ export namespace languages {
|
|
|
7308
7328
|
* Will be called when a completions list is no longer in use and can be garbage-collected.
|
|
7309
7329
|
*/
|
|
7310
7330
|
disposeInlineCompletions(completions: T, reason: InlineCompletionsDisposeReason): void;
|
|
7311
|
-
|
|
7331
|
+
/**
|
|
7332
|
+
* Fired when the provider wants to trigger a new completion request.
|
|
7333
|
+
* The event can pass a {@link IInlineCompletionChangeHint} which will be
|
|
7334
|
+
* included in the {@link InlineCompletionContext} of the subsequent request.
|
|
7335
|
+
*/
|
|
7336
|
+
onDidChangeInlineCompletions?: IEvent<IInlineCompletionChangeHint | void>;
|
|
7312
7337
|
/**
|
|
7313
7338
|
* Only used for {@link yieldsToGroupIds}.
|
|
7314
7339
|
* Multiple providers can have the same group id.
|
|
@@ -8,30 +8,32 @@ import { renderViewLine2, RenderLineInput } from '@codingame/monaco-vscode-api/v
|
|
|
8
8
|
import { ViewLineRenderingData } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/viewModel';
|
|
9
9
|
import { MonarchTokenizer } from '../common/monarch/monarchLexer.js';
|
|
10
10
|
|
|
11
|
-
const ttPolicy = createTrustedTypesPolicy(
|
|
11
|
+
const ttPolicy = createTrustedTypesPolicy("standaloneColorizer", {
|
|
12
|
+
createHTML: value => value
|
|
13
|
+
});
|
|
12
14
|
class Colorizer {
|
|
13
15
|
static colorizeElement(themeService, languageService, domNode, options) {
|
|
14
16
|
options = options || {};
|
|
15
|
-
const theme = options.theme ||
|
|
16
|
-
const mimeType = options.mimeType || domNode.getAttribute(
|
|
17
|
+
const theme = options.theme || "vs";
|
|
18
|
+
const mimeType = options.mimeType || domNode.getAttribute("lang") || domNode.getAttribute("data-lang");
|
|
17
19
|
if (!mimeType) {
|
|
18
|
-
console.error(
|
|
20
|
+
console.error("Mode not detected");
|
|
19
21
|
return Promise.resolve();
|
|
20
22
|
}
|
|
21
23
|
const languageId = languageService.getLanguageIdByMimeType(mimeType) || mimeType;
|
|
22
24
|
themeService.setTheme(theme);
|
|
23
|
-
const text = domNode.firstChild ? domNode.firstChild.nodeValue :
|
|
24
|
-
domNode.className +=
|
|
25
|
-
const render =
|
|
25
|
+
const text = domNode.firstChild ? domNode.firstChild.nodeValue : "";
|
|
26
|
+
domNode.className += " " + theme;
|
|
27
|
+
const render = str => {
|
|
26
28
|
const trustedhtml = ttPolicy?.createHTML(str) ?? str;
|
|
27
29
|
domNode.innerHTML = trustedhtml;
|
|
28
30
|
};
|
|
29
|
-
return this.colorize(languageService, text ||
|
|
31
|
+
return this.colorize(languageService, text || "", languageId, options).then(render, err => console.error(err));
|
|
30
32
|
}
|
|
31
33
|
static async colorize(languageService, text, languageId, options) {
|
|
32
34
|
const languageIdCodec = languageService.languageIdCodec;
|
|
33
35
|
let tabSize = 4;
|
|
34
|
-
if (options && typeof options.tabSize ===
|
|
36
|
+
if (options && typeof options.tabSize === "number") {
|
|
35
37
|
tabSize = options.tabSize;
|
|
36
38
|
}
|
|
37
39
|
if (startsWithUTF8BOM(text)) {
|
|
@@ -66,7 +68,7 @@ class Colorizer {
|
|
|
66
68
|
0,
|
|
67
69
|
0,
|
|
68
70
|
-1,
|
|
69
|
-
|
|
71
|
+
"none",
|
|
70
72
|
false,
|
|
71
73
|
false,
|
|
72
74
|
null,
|
|
@@ -80,7 +82,13 @@ class Colorizer {
|
|
|
80
82
|
model.tokenization.forceTokenization(lineNumber);
|
|
81
83
|
const tokens = model.tokenization.getLineTokens(lineNumber);
|
|
82
84
|
const inflatedTokens = tokens.inflate();
|
|
83
|
-
return this.colorizeLine(
|
|
85
|
+
return this.colorizeLine(
|
|
86
|
+
content,
|
|
87
|
+
model.mightContainNonBasicASCII(),
|
|
88
|
+
model.mightContainRTL(),
|
|
89
|
+
inflatedTokens,
|
|
90
|
+
tabSize
|
|
91
|
+
);
|
|
84
92
|
}
|
|
85
93
|
}
|
|
86
94
|
function _colorize(lines, tabSize, tokenizationSupport, languageIdCodec) {
|
|
@@ -101,9 +109,7 @@ function _colorize(lines, tabSize, tokenizationSupport, languageIdCodec) {
|
|
|
101
109
|
}
|
|
102
110
|
function _fakeColorize(lines, tabSize, languageIdCodec) {
|
|
103
111
|
let html = [];
|
|
104
|
-
const defaultMetadata = ((FontStyle.None << MetadataConsts.FONT_STYLE_OFFSET)
|
|
105
|
-
| (ColorId.DefaultForeground << MetadataConsts.FOREGROUND_OFFSET)
|
|
106
|
-
| (ColorId.DefaultBackground << MetadataConsts.BACKGROUND_OFFSET)) >>> 0;
|
|
112
|
+
const defaultMetadata = ((FontStyle.None << MetadataConsts.FONT_STYLE_OFFSET) | (ColorId.DefaultForeground << MetadataConsts.FOREGROUND_OFFSET) | (ColorId.DefaultBackground << MetadataConsts.BACKGROUND_OFFSET)) >>> 0;
|
|
107
113
|
const tokens = ( new Uint32Array(2));
|
|
108
114
|
tokens[0] = 0;
|
|
109
115
|
tokens[1] = defaultMetadata;
|
|
@@ -129,7 +135,7 @@ function _fakeColorize(lines, tabSize, languageIdCodec) {
|
|
|
129
135
|
0,
|
|
130
136
|
0,
|
|
131
137
|
-1,
|
|
132
|
-
|
|
138
|
+
"none",
|
|
133
139
|
false,
|
|
134
140
|
false,
|
|
135
141
|
null,
|
|
@@ -137,9 +143,9 @@ function _fakeColorize(lines, tabSize, languageIdCodec) {
|
|
|
137
143
|
0
|
|
138
144
|
)));
|
|
139
145
|
html = html.concat(renderResult.html);
|
|
140
|
-
html.push(
|
|
146
|
+
html.push("<br/>");
|
|
141
147
|
}
|
|
142
|
-
return html.join(
|
|
148
|
+
return html.join("");
|
|
143
149
|
}
|
|
144
150
|
function _actualColorize(lines, tabSize, tokenizationSupport, languageIdCodec) {
|
|
145
151
|
let html = [];
|
|
@@ -167,7 +173,7 @@ function _actualColorize(lines, tabSize, tokenizationSupport, languageIdCodec) {
|
|
|
167
173
|
0,
|
|
168
174
|
0,
|
|
169
175
|
-1,
|
|
170
|
-
|
|
176
|
+
"none",
|
|
171
177
|
false,
|
|
172
178
|
false,
|
|
173
179
|
null,
|
|
@@ -175,10 +181,10 @@ function _actualColorize(lines, tabSize, tokenizationSupport, languageIdCodec) {
|
|
|
175
181
|
0
|
|
176
182
|
)));
|
|
177
183
|
html = html.concat(renderResult.html);
|
|
178
|
-
html.push(
|
|
184
|
+
html.push("<br/>");
|
|
179
185
|
state = tokenizeResult.endState;
|
|
180
186
|
}
|
|
181
|
-
return html.join(
|
|
187
|
+
return html.join("");
|
|
182
188
|
}
|
|
183
189
|
|
|
184
190
|
export { Colorizer };
|
|
@@ -40,13 +40,13 @@ function create(domElement, options, override) {
|
|
|
40
40
|
}
|
|
41
41
|
function onDidCreateEditor(listener) {
|
|
42
42
|
const codeEditorService = StandaloneServices.get(ICodeEditorService);
|
|
43
|
-
return codeEditorService.onCodeEditorAdd(
|
|
43
|
+
return codeEditorService.onCodeEditorAdd(editor => {
|
|
44
44
|
listener(editor);
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
function onDidCreateDiffEditor(listener) {
|
|
48
48
|
const codeEditorService = StandaloneServices.get(ICodeEditorService);
|
|
49
|
-
return codeEditorService.onDiffEditorAdd(
|
|
49
|
+
return codeEditorService.onDiffEditorAdd(editor => {
|
|
50
50
|
listener(editor);
|
|
51
51
|
});
|
|
52
52
|
}
|
|
@@ -67,20 +67,25 @@ function createMultiFileDiffEditor(domElement, override) {
|
|
|
67
67
|
return ( new MultiDiffEditorWidget(domElement, {}, instantiationService));
|
|
68
68
|
}
|
|
69
69
|
function addCommand(descriptor) {
|
|
70
|
-
if ((typeof descriptor.id !==
|
|
71
|
-
throw ( new Error(
|
|
70
|
+
if ((typeof descriptor.id !== "string") || (typeof descriptor.run !== "function")) {
|
|
71
|
+
throw ( new Error("Invalid command descriptor, `id` and `run` are required properties!"));
|
|
72
72
|
}
|
|
73
73
|
return CommandsRegistry.registerCommand(descriptor.id, descriptor.run);
|
|
74
74
|
}
|
|
75
75
|
function addEditorAction(descriptor) {
|
|
76
|
-
if ((typeof descriptor.id !==
|
|
76
|
+
if ((typeof descriptor.id !== "string") || (typeof descriptor.label !== "string") || (typeof descriptor.run !== "function")) {
|
|
77
77
|
throw ( new Error(
|
|
78
|
-
|
|
78
|
+
"Invalid action descriptor, `id`, `label` and `run` are required properties!"
|
|
79
79
|
));
|
|
80
80
|
}
|
|
81
81
|
const precondition = ContextKeyExpr.deserialize(descriptor.precondition);
|
|
82
82
|
const run = (accessor, ...args) => {
|
|
83
|
-
return EditorCommand.runEditorCommand(
|
|
83
|
+
return EditorCommand.runEditorCommand(
|
|
84
|
+
accessor,
|
|
85
|
+
args,
|
|
86
|
+
precondition,
|
|
87
|
+
(accessor, editor, args) => Promise.resolve(descriptor.run(editor, ...args))
|
|
88
|
+
);
|
|
84
89
|
};
|
|
85
90
|
const toDispose = ( new DisposableStore());
|
|
86
91
|
toDispose.add(CommandsRegistry.registerCommand(descriptor.id, run));
|
|
@@ -99,11 +104,12 @@ function addEditorAction(descriptor) {
|
|
|
99
104
|
if (Array.isArray(descriptor.keybindings)) {
|
|
100
105
|
const keybindingService = StandaloneServices.get(IKeybindingService);
|
|
101
106
|
if (!(keybindingService instanceof StandaloneKeybindingService)) {
|
|
102
|
-
console.warn(
|
|
103
|
-
|
|
104
|
-
|
|
107
|
+
console.warn(
|
|
108
|
+
"Cannot add keybinding because the editor is configured with an unrecognized KeybindingService"
|
|
109
|
+
);
|
|
110
|
+
} else {
|
|
105
111
|
const keybindingsWhen = ( ContextKeyExpr.and(precondition, ContextKeyExpr.deserialize(descriptor.keybindingContext)));
|
|
106
|
-
toDispose.add(keybindingService.addDynamicKeybindings(( descriptor.keybindings.map(
|
|
112
|
+
toDispose.add(keybindingService.addDynamicKeybindings(( descriptor.keybindings.map(keybinding => {
|
|
107
113
|
return {
|
|
108
114
|
keybinding,
|
|
109
115
|
command: descriptor.id,
|
|
@@ -120,22 +126,30 @@ function addKeybindingRule(rule) {
|
|
|
120
126
|
function addKeybindingRules(rules) {
|
|
121
127
|
const keybindingService = StandaloneServices.get(IKeybindingService);
|
|
122
128
|
if (!(keybindingService instanceof StandaloneKeybindingService)) {
|
|
123
|
-
console.warn(
|
|
129
|
+
console.warn(
|
|
130
|
+
"Cannot add keybinding because the editor is configured with an unrecognized KeybindingService"
|
|
131
|
+
);
|
|
124
132
|
return Disposable.None;
|
|
125
133
|
}
|
|
126
|
-
return keybindingService.addDynamicKeybindings(( rules.map(
|
|
134
|
+
return keybindingService.addDynamicKeybindings(( rules.map(rule => {
|
|
127
135
|
return {
|
|
128
136
|
keybinding: rule.keybinding,
|
|
129
137
|
command: rule.command,
|
|
130
138
|
commandArgs: rule.commandArgs,
|
|
131
|
-
when: ContextKeyExpr.deserialize(rule.when)
|
|
139
|
+
when: ContextKeyExpr.deserialize(rule.when)
|
|
132
140
|
};
|
|
133
141
|
})));
|
|
134
142
|
}
|
|
135
143
|
function createModel(value, language, uri) {
|
|
136
144
|
const languageService = StandaloneServices.get(ILanguageService);
|
|
137
145
|
const languageId = languageService.getLanguageIdByMimeType(language) || language;
|
|
138
|
-
return createTextModel(
|
|
146
|
+
return createTextModel(
|
|
147
|
+
StandaloneServices.get(IModelService),
|
|
148
|
+
languageService,
|
|
149
|
+
value,
|
|
150
|
+
languageId,
|
|
151
|
+
uri
|
|
152
|
+
);
|
|
139
153
|
}
|
|
140
154
|
function setModelLanguage(model, mimeTypeOrLanguageId) {
|
|
141
155
|
const languageService = StandaloneServices.get(ILanguageService);
|
|
@@ -178,7 +192,7 @@ function onWillDisposeModel(listener) {
|
|
|
178
192
|
}
|
|
179
193
|
function onDidChangeModelLanguage(listener) {
|
|
180
194
|
const modelService = StandaloneServices.get(IModelService);
|
|
181
|
-
return modelService.onModelLanguageChanged(
|
|
195
|
+
return modelService.onModelLanguageChanged(e => {
|
|
182
196
|
listener({
|
|
183
197
|
model: e.model,
|
|
184
198
|
oldLanguage: e.oldLanguageId
|
|
@@ -186,7 +200,11 @@ function onDidChangeModelLanguage(listener) {
|
|
|
186
200
|
});
|
|
187
201
|
}
|
|
188
202
|
function createWebWorker(opts) {
|
|
189
|
-
return createWebWorker$1(
|
|
203
|
+
return createWebWorker$1(
|
|
204
|
+
StandaloneServices.get(IModelService),
|
|
205
|
+
StandaloneServices.get(IWebWorkerService),
|
|
206
|
+
opts
|
|
207
|
+
);
|
|
190
208
|
}
|
|
191
209
|
function colorizeElement(domNode, options) {
|
|
192
210
|
const languageService = StandaloneServices.get(ILanguageService);
|
|
@@ -242,13 +260,16 @@ function remeasureFonts() {
|
|
|
242
260
|
FontMeasurements.clearAllFontInfos();
|
|
243
261
|
}
|
|
244
262
|
function registerCommand(id, handler) {
|
|
245
|
-
return CommandsRegistry.registerCommand({
|
|
263
|
+
return CommandsRegistry.registerCommand({
|
|
264
|
+
id,
|
|
265
|
+
handler
|
|
266
|
+
});
|
|
246
267
|
}
|
|
247
268
|
function registerLinkOpener(opener) {
|
|
248
269
|
const openerService = StandaloneServices.get(IOpenerService);
|
|
249
270
|
return openerService.registerOpener({
|
|
250
271
|
async open(resource) {
|
|
251
|
-
if (typeof resource ===
|
|
272
|
+
if (typeof resource === "string") {
|
|
252
273
|
resource = ( URI.parse(resource));
|
|
253
274
|
}
|
|
254
275
|
return opener.open(resource);
|
|
@@ -263,11 +284,13 @@ function registerEditorOpener(opener) {
|
|
|
263
284
|
}
|
|
264
285
|
const selection = input.options?.selection;
|
|
265
286
|
let selectionOrPosition;
|
|
266
|
-
if (selection && typeof selection.endLineNumber ===
|
|
287
|
+
if (selection && typeof selection.endLineNumber === "number" && typeof selection.endColumn === "number") {
|
|
267
288
|
selectionOrPosition = selection;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
|
|
289
|
+
} else if (selection) {
|
|
290
|
+
selectionOrPosition = {
|
|
291
|
+
lineNumber: selection.startLineNumber,
|
|
292
|
+
column: selection.startColumn
|
|
293
|
+
};
|
|
271
294
|
}
|
|
272
295
|
if (await opener.openCodeEditor(source, input.resource, selectionOrPosition)) {
|
|
273
296
|
return source;
|
|
@@ -31,7 +31,7 @@ function getEncodedLanguageId(languageId) {
|
|
|
31
31
|
function onLanguage(languageId, callback) {
|
|
32
32
|
return StandaloneServices.withServices(() => {
|
|
33
33
|
const languageService = StandaloneServices.get(ILanguageService);
|
|
34
|
-
const disposable = languageService.onDidRequestRichLanguageFeatures(
|
|
34
|
+
const disposable = languageService.onDidRequestRichLanguageFeatures(encounteredLanguageId => {
|
|
35
35
|
if (encounteredLanguageId === languageId) {
|
|
36
36
|
disposable.dispose();
|
|
37
37
|
callback();
|
|
@@ -43,7 +43,7 @@ function onLanguage(languageId, callback) {
|
|
|
43
43
|
function onLanguageEncountered(languageId, callback) {
|
|
44
44
|
return StandaloneServices.withServices(() => {
|
|
45
45
|
const languageService = StandaloneServices.get(ILanguageService);
|
|
46
|
-
const disposable = languageService.onDidRequestBasicLanguageFeatures(
|
|
46
|
+
const disposable = languageService.onDidRequestBasicLanguageFeatures(encounteredLanguageId => {
|
|
47
47
|
if (encounteredLanguageId === languageId) {
|
|
48
48
|
disposable.dispose();
|
|
49
49
|
callback();
|
|
@@ -65,16 +65,15 @@ class EncodedTokenizationSupportAdapter {
|
|
|
65
65
|
this._languageId = languageId;
|
|
66
66
|
this._actual = actual;
|
|
67
67
|
}
|
|
68
|
-
dispose() {
|
|
69
|
-
}
|
|
68
|
+
dispose() {}
|
|
70
69
|
getInitialState() {
|
|
71
70
|
return this._actual.getInitialState();
|
|
72
71
|
}
|
|
73
72
|
tokenize(line, hasEOL, state) {
|
|
74
|
-
if (typeof this._actual.tokenize ===
|
|
73
|
+
if (typeof this._actual.tokenize === "function") {
|
|
75
74
|
return TokenizationSupportAdapter.adaptTokenize(this._languageId, this._actual, line, state);
|
|
76
75
|
}
|
|
77
|
-
throw ( new Error(
|
|
76
|
+
throw ( new Error("Not supported!"));
|
|
78
77
|
}
|
|
79
78
|
tokenizeEncoded(line, hasEOL, state) {
|
|
80
79
|
const result = this._actual.tokenizeEncoded(line, state);
|
|
@@ -88,8 +87,7 @@ class TokenizationSupportAdapter {
|
|
|
88
87
|
this._languageService = _languageService;
|
|
89
88
|
this._standaloneThemeService = _standaloneThemeService;
|
|
90
89
|
}
|
|
91
|
-
dispose() {
|
|
92
|
-
}
|
|
90
|
+
dispose() {}
|
|
93
91
|
getInitialState() {
|
|
94
92
|
return this._actual.getInitialState();
|
|
95
93
|
}
|
|
@@ -101,8 +99,7 @@ class TokenizationSupportAdapter {
|
|
|
101
99
|
let startIndex = t.startIndex;
|
|
102
100
|
if (i === 0) {
|
|
103
101
|
startIndex = 0;
|
|
104
|
-
}
|
|
105
|
-
else if (startIndex < previousStartIndex) {
|
|
102
|
+
} else if (startIndex < previousStartIndex) {
|
|
106
103
|
startIndex = previousStartIndex;
|
|
107
104
|
}
|
|
108
105
|
result[i] = new Token(startIndex, t.scopes, language);
|
|
@@ -116,8 +113,7 @@ class TokenizationSupportAdapter {
|
|
|
116
113
|
let endState;
|
|
117
114
|
if (actualResult.endState.equals(state)) {
|
|
118
115
|
endState = state;
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
116
|
+
} else {
|
|
121
117
|
endState = actualResult.endState;
|
|
122
118
|
}
|
|
123
119
|
return new TokenizationResult(tokens, endState);
|
|
@@ -140,8 +136,7 @@ class TokenizationSupportAdapter {
|
|
|
140
136
|
let startIndex = t.startIndex;
|
|
141
137
|
if (i === 0) {
|
|
142
138
|
startIndex = 0;
|
|
143
|
-
}
|
|
144
|
-
else if (startIndex < previousStartIndex) {
|
|
139
|
+
} else if (startIndex < previousStartIndex) {
|
|
145
140
|
startIndex = previousStartIndex;
|
|
146
141
|
}
|
|
147
142
|
result[resultLen++] = startIndex;
|
|
@@ -160,21 +155,20 @@ class TokenizationSupportAdapter {
|
|
|
160
155
|
let endState;
|
|
161
156
|
if (actualResult.endState.equals(state)) {
|
|
162
157
|
endState = state;
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
158
|
+
} else {
|
|
165
159
|
endState = actualResult.endState;
|
|
166
160
|
}
|
|
167
161
|
return new EncodedTokenizationResult(tokens, [], endState);
|
|
168
162
|
}
|
|
169
163
|
}
|
|
170
164
|
function isATokensProvider(provider) {
|
|
171
|
-
return (typeof provider.getInitialState ===
|
|
165
|
+
return (typeof provider.getInitialState === "function");
|
|
172
166
|
}
|
|
173
167
|
function isEncodedTokensProvider(provider) {
|
|
174
|
-
return
|
|
168
|
+
return "tokenizeEncoded" in provider;
|
|
175
169
|
}
|
|
176
170
|
function isThenable(obj) {
|
|
177
|
-
return obj && typeof obj.then ===
|
|
171
|
+
return obj && typeof obj.then === "function";
|
|
178
172
|
}
|
|
179
173
|
function setColorMap(colorMap) {
|
|
180
174
|
const standaloneThemeService = StandaloneServices.get(IStandaloneThemeService);
|
|
@@ -184,16 +178,14 @@ function setColorMap(colorMap) {
|
|
|
184
178
|
result[i] = ( Color.fromHex(colorMap[i]));
|
|
185
179
|
}
|
|
186
180
|
standaloneThemeService.setColorMapOverride(result);
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
181
|
+
} else {
|
|
189
182
|
standaloneThemeService.setColorMapOverride(null);
|
|
190
183
|
}
|
|
191
184
|
}
|
|
192
185
|
function createTokenizationSupportAdapter(languageId, provider) {
|
|
193
186
|
if (isEncodedTokensProvider(provider)) {
|
|
194
187
|
return ( new EncodedTokenizationSupportAdapter(languageId, provider));
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
188
|
+
} else {
|
|
197
189
|
return ( new TokenizationSupportAdapter(
|
|
198
190
|
languageId,
|
|
199
191
|
provider,
|
|
@@ -227,12 +219,14 @@ function setTokensProvider(languageId, provider) {
|
|
|
227
219
|
throw ( new Error(`Cannot set tokens provider for unknown language ${languageId}`));
|
|
228
220
|
}
|
|
229
221
|
if (isThenable(provider)) {
|
|
230
|
-
return registerTokensProviderFactory(languageId, {
|
|
222
|
+
return registerTokensProviderFactory(languageId, {
|
|
223
|
+
create: () => provider
|
|
224
|
+
});
|
|
231
225
|
}
|
|
232
226
|
return TokenizationRegistry.register(languageId, createTokenizationSupportAdapter(languageId, provider));
|
|
233
227
|
}
|
|
234
228
|
function setMonarchTokensProvider(languageId, languageDef) {
|
|
235
|
-
const create =
|
|
229
|
+
const create = languageDef => {
|
|
236
230
|
return ( new MonarchTokenizer(
|
|
237
231
|
StandaloneServices.get(ILanguageService),
|
|
238
232
|
StandaloneServices.get(IStandaloneThemeService),
|
|
@@ -242,7 +236,9 @@ function setMonarchTokensProvider(languageId, languageDef) {
|
|
|
242
236
|
));
|
|
243
237
|
};
|
|
244
238
|
if (isThenable(languageDef)) {
|
|
245
|
-
return registerTokensProviderFactory(languageId, {
|
|
239
|
+
return registerTokensProviderFactory(languageId, {
|
|
240
|
+
create: () => languageDef
|
|
241
|
+
});
|
|
246
242
|
}
|
|
247
243
|
return TokenizationRegistry.register(languageId, create(languageDef));
|
|
248
244
|
}
|
|
@@ -267,7 +263,7 @@ function registerHoverProvider(languageSelector, provider) {
|
|
|
267
263
|
return languageFeaturesService.hoverProvider.register(languageSelector, {
|
|
268
264
|
provideHover: async (model, position, token, context) => {
|
|
269
265
|
const word = model.getWordAtPosition(position);
|
|
270
|
-
return Promise.resolve(provider.provideHover(model, position, token, context)).then(
|
|
266
|
+
return Promise.resolve(provider.provideHover(model, position, token, context)).then(value => {
|
|
271
267
|
if (!value) {
|
|
272
268
|
return undefined;
|
|
273
269
|
}
|
|
@@ -317,10 +313,16 @@ function registerCodeActionProvider(languageSelector, provider, metadata) {
|
|
|
317
313
|
documentation: metadata?.documentation,
|
|
318
314
|
provideCodeActions: (model, range, context, token) => {
|
|
319
315
|
const markerService = StandaloneServices.get(IMarkerService);
|
|
320
|
-
const markers = markerService.read({
|
|
316
|
+
const markers = markerService.read({
|
|
317
|
+
resource: model.uri
|
|
318
|
+
}).filter(m => {
|
|
321
319
|
return Range.areIntersectingOrTouching(m, range);
|
|
322
320
|
});
|
|
323
|
-
return provider.provideCodeActions(model, range, {
|
|
321
|
+
return provider.provideCodeActions(model, range, {
|
|
322
|
+
markers,
|
|
323
|
+
only: context.only,
|
|
324
|
+
trigger: context.trigger
|
|
325
|
+
}, token);
|
|
324
326
|
},
|
|
325
327
|
resolveCodeAction: provider.resolveCodeAction
|
|
326
328
|
});
|
|
@@ -435,7 +437,7 @@ function createMonacoLanguagesAPI() {
|
|
|
435
437
|
InlineCompletionHintStyle: InlineCompletionHintStyle,
|
|
436
438
|
FoldingRangeKind: FoldingRangeKind,
|
|
437
439
|
SelectedSuggestionInfo: SelectedSuggestionInfo,
|
|
438
|
-
EditDeltaInfo: EditDeltaInfo
|
|
440
|
+
EditDeltaInfo: EditDeltaInfo
|
|
439
441
|
};
|
|
440
442
|
}
|
|
441
443
|
|
|
@@ -11,13 +11,13 @@ class MonacoWebWorkerImpl extends EditorWorkerClient {
|
|
|
11
11
|
this._foreignProxy = this._getProxy().then(proxy => {
|
|
12
12
|
return ( new Proxy({}, {
|
|
13
13
|
get(target, prop, receiver) {
|
|
14
|
-
if (prop ===
|
|
14
|
+
if (prop === "then") {
|
|
15
15
|
return undefined;
|
|
16
16
|
}
|
|
17
|
-
if (typeof prop !==
|
|
17
|
+
if (typeof prop !== "string") {
|
|
18
18
|
throw ( new Error(`Not supported`));
|
|
19
19
|
}
|
|
20
|
-
if (prop ===
|
|
20
|
+
if (prop === "then") {
|
|
21
21
|
return undefined;
|
|
22
22
|
}
|
|
23
23
|
return (...args) => {
|
|
@@ -28,13 +28,12 @@ class MonacoWebWorkerImpl extends EditorWorkerClient {
|
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
fhr(method, args) {
|
|
31
|
-
if (!this._foreignModuleHost || typeof this._foreignModuleHost[method] !==
|
|
32
|
-
return Promise.reject(( new Error(
|
|
31
|
+
if (!this._foreignModuleHost || typeof this._foreignModuleHost[method] !== "function") {
|
|
32
|
+
return Promise.reject(( new Error("Missing method " + method + " or missing main thread foreign host.")));
|
|
33
33
|
}
|
|
34
34
|
try {
|
|
35
35
|
return Promise.resolve(this._foreignModuleHost[method].apply(this._foreignModuleHost, args));
|
|
36
|
-
}
|
|
37
|
-
catch (e) {
|
|
36
|
+
} catch (e) {
|
|
38
37
|
return Promise.reject(e);
|
|
39
38
|
}
|
|
40
39
|
}
|