@kusto/monaco-kusto 8.2.0 → 8.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/package.json +16 -16
  2. package/release/dev/Kusto.Language.Bridge.min.js +1 -1
  3. package/release/dev/kusto.javascript.client.min.js +1 -1
  4. package/release/dev/kustoMode.js +21 -21
  5. package/release/dev/kustoWorker.js +23 -21
  6. package/release/dev/{main-f25d1ca7.js → main-e6ef956d.js} +168 -381
  7. package/release/dev/monaco.contribution.js +6 -9
  8. package/release/dev/{schema-8dc56616.js → schema-7d65ed04.js} +4 -4
  9. package/release/esm/commandFormatter.js +37 -0
  10. package/release/esm/commandHighlighter.js +52 -0
  11. package/release/esm/extendedEditor.js +41 -0
  12. package/release/esm/kusto.worker.js +2 -2
  13. package/release/esm/kustoMode.js +139 -1158
  14. package/release/esm/kustoWorker.js +252 -0
  15. package/release/esm/languageFeatures.js +1072 -0
  16. package/release/esm/languageService/kustoLanguageService.js +1923 -0
  17. package/release/esm/languageService/kustoMonarchLanguageDefinition.js +211 -0
  18. package/release/esm/languageService/renderInfo.js +1 -0
  19. package/release/esm/languageService/schema.js +64 -0
  20. package/release/esm/languageService/settings.js +1 -0
  21. package/release/esm/monaco.contribution.js +178 -426
  22. package/release/esm/{schema-1d41f705.js → schema-ee621489.js} +1 -2
  23. package/release/esm/types.js +1 -0
  24. package/release/esm/workerManager.js +102 -0
  25. package/release/min/Kusto.Language.Bridge.min.js +1 -1
  26. package/release/min/kusto.javascript.client.min.js +1 -1
  27. package/release/min/kustoMode.js +2 -2
  28. package/release/min/kustoWorker.js +2 -2
  29. package/release/min/main-04a9f035.js +7 -0
  30. package/release/min/monaco.contribution.js +2 -2
  31. package/release/min/{schema-ef0ffe13.js → schema-095fdf5a.js} +2 -2
  32. package/release/min/main-c1317e01.js +0 -7
@@ -0,0 +1,1072 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
38
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
39
+ if (ar || !(i in from)) {
40
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
41
+ ar[i] = from[i];
42
+ }
43
+ }
44
+ return to.concat(ar || Array.prototype.slice.call(from));
45
+ };
46
+ import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
47
+ import * as ls from 'vscode-languageserver-types';
48
+ import debounce from 'lodash-es/debounce';
49
+ var DiagnosticsAdapter = /** @class */ (function () {
50
+ function DiagnosticsAdapter(_monacoInstance, _languageId, _worker, defaults, onSchemaChange) {
51
+ var _this = this;
52
+ this._monacoInstance = _monacoInstance;
53
+ this._languageId = _languageId;
54
+ this._worker = _worker;
55
+ this.defaults = defaults;
56
+ this._disposables = [];
57
+ this._contentListener = Object.create(null);
58
+ this._configurationListener = Object.create(null);
59
+ this._schemaListener = Object.create(null);
60
+ this._cursorListener = Object.create(null);
61
+ this._debouncedValidations = Object.create(null);
62
+ var onModelAdd = function (model) {
63
+ var languageId = model.getLanguageId();
64
+ var modelUri = model.uri.toString();
65
+ if (languageId !== _this._languageId) {
66
+ return;
67
+ }
68
+ var debouncedValidation = _this.getOrCreateDebouncedValidation(model, languageId);
69
+ _this._contentListener[modelUri] = model.onDidChangeContent(function (e) {
70
+ var intervalsToValidate = changeEventToIntervals(e);
71
+ debouncedValidation(intervalsToValidate);
72
+ });
73
+ _this._configurationListener[modelUri] = _this.defaults.onDidChange(function () {
74
+ self.setTimeout(function () { return _this._doValidate(model, languageId, []); }, 0);
75
+ });
76
+ _this._schemaListener[modelUri] = onSchemaChange(function () {
77
+ self.setTimeout(function () { return _this._doValidate(model, languageId, []); }, 0);
78
+ });
79
+ };
80
+ var onEditorAdd = function (editor) {
81
+ var editorId = editor.getId();
82
+ if (!_this._cursorListener[editorId]) {
83
+ editor.onDidDispose(function () {
84
+ var _a;
85
+ (_a = _this._cursorListener[editorId]) === null || _a === void 0 ? void 0 : _a.dispose();
86
+ delete _this._cursorListener[editorId];
87
+ });
88
+ _this._cursorListener[editorId] = editor.onDidChangeCursorSelection(function (e) {
89
+ var model = editor.getModel();
90
+ var languageId = model.getLanguageId();
91
+ if (languageId !== _this._languageId) {
92
+ return;
93
+ }
94
+ var cursorOffset = model.getOffsetAt(e.selection.getPosition());
95
+ var debouncedValidation = _this.getOrCreateDebouncedValidation(model, languageId);
96
+ debouncedValidation([{ start: cursorOffset, end: cursorOffset }]);
97
+ });
98
+ }
99
+ };
100
+ var onModelRemoved = function (model) {
101
+ _this._monacoInstance.editor.setModelMarkers(model, _this._languageId, []);
102
+ var uriStr = model.uri.toString();
103
+ var contentListener = _this._contentListener[uriStr];
104
+ if (contentListener) {
105
+ contentListener.dispose();
106
+ delete _this._contentListener[uriStr];
107
+ }
108
+ var configurationListener = _this._configurationListener[uriStr];
109
+ if (configurationListener) {
110
+ configurationListener.dispose();
111
+ delete _this._configurationListener[uriStr];
112
+ }
113
+ var schemaListener = _this._schemaListener[uriStr];
114
+ if (schemaListener) {
115
+ schemaListener.dispose();
116
+ delete _this._schemaListener[uriStr];
117
+ }
118
+ var debouncedValidation = _this._debouncedValidations[uriStr];
119
+ if (debouncedValidation) {
120
+ debouncedValidation.cancel();
121
+ delete _this._debouncedValidations[uriStr];
122
+ }
123
+ };
124
+ if (this.defaults.languageSettings.enableQuickFixes) {
125
+ this._disposables.push(monaco.languages.registerCodeActionProvider(this._languageId, {
126
+ provideCodeActions: function (model, range, context, _token) { return __awaiter(_this, void 0, void 0, function () {
127
+ var startOffset, endOffset, showQuickFix, actions;
128
+ return __generator(this, function (_a) {
129
+ switch (_a.label) {
130
+ case 0:
131
+ startOffset = model.getOffsetAt(range.getStartPosition());
132
+ endOffset = model.getOffsetAt(range.getEndPosition());
133
+ showQuickFix = context.markers.length > 0;
134
+ return [4 /*yield*/, this.getMonacoCodeActions(model, startOffset, endOffset, showQuickFix)];
135
+ case 1:
136
+ actions = _a.sent();
137
+ return [2 /*return*/, {
138
+ actions: actions,
139
+ dispose: function () { },
140
+ }];
141
+ }
142
+ });
143
+ }); },
144
+ }));
145
+ }
146
+ this._disposables.push(this._monacoInstance.editor.onDidCreateEditor(onEditorAdd));
147
+ this._disposables.push(this._monacoInstance.editor.onDidCreateModel(onModelAdd));
148
+ this._disposables.push(this._monacoInstance.editor.onWillDisposeModel(onModelRemoved));
149
+ this._disposables.push(this._monacoInstance.editor.onDidChangeModelLanguage(function (event) {
150
+ onModelRemoved(event.model);
151
+ onModelAdd(event.model);
152
+ }));
153
+ this._disposables.push({
154
+ dispose: function () {
155
+ for (var key in _this._contentListener) {
156
+ _this._contentListener[key].dispose();
157
+ }
158
+ for (var key in _this._cursorListener) {
159
+ _this._cursorListener[key].dispose();
160
+ }
161
+ for (var key in _this._debouncedValidations) {
162
+ _this._debouncedValidations[key].cancel();
163
+ }
164
+ },
165
+ });
166
+ this._monacoInstance.editor.getModels().forEach(onModelAdd);
167
+ this._monacoInstance.editor.getEditors().forEach(onEditorAdd);
168
+ }
169
+ DiagnosticsAdapter.prototype.getMonacoCodeActions = function (model, startOffset, endOffset, enableQuickFix) {
170
+ var _a;
171
+ return __awaiter(this, void 0, void 0, function () {
172
+ var actions, worker, resource, codeActions, _loop_1, this_1, i, state_1;
173
+ return __generator(this, function (_b) {
174
+ switch (_b.label) {
175
+ case 0:
176
+ actions = [];
177
+ return [4 /*yield*/, this._worker(model.uri)];
178
+ case 1:
179
+ worker = _b.sent();
180
+ resource = model.uri;
181
+ return [4 /*yield*/, worker.getResultActions(resource.toString(), startOffset, endOffset)];
182
+ case 2:
183
+ codeActions = _b.sent();
184
+ _loop_1 = function (i) {
185
+ var codeAction = codeActions[i];
186
+ if (codeAction.kind.includes('Extract Function')) {
187
+ return "continue";
188
+ }
189
+ var codeActionKind = ((_a = this_1.defaults.languageSettings.quickFixCodeActions) === null || _a === void 0 ? void 0 : _a.find(function (actionKind) {
190
+ return codeAction.kind.includes(actionKind);
191
+ }))
192
+ ? 'quickfix'
193
+ : 'custom';
194
+ if (codeActionKind === 'quickfix' && !enableQuickFix) {
195
+ return { value: void 0 };
196
+ }
197
+ var changes = codeAction.changes;
198
+ var edits = changes.map(function (change) {
199
+ var _a;
200
+ var startPosition = model.getPositionAt(change.start);
201
+ var endPosition = model.getPositionAt(change.start + change.deleteLength);
202
+ return {
203
+ resource: model.uri,
204
+ textEdit: {
205
+ range: {
206
+ startLineNumber: startPosition.lineNumber,
207
+ startColumn: startPosition.column,
208
+ endLineNumber: endPosition.lineNumber,
209
+ endColumn: endPosition.column,
210
+ },
211
+ text: (_a = change.insertText) !== null && _a !== void 0 ? _a : '',
212
+ },
213
+ };
214
+ });
215
+ actions.push({
216
+ title: codeAction.title,
217
+ diagnostics: [],
218
+ kind: codeActionKind,
219
+ edit: {
220
+ edits: __spreadArray([], edits, true),
221
+ },
222
+ });
223
+ };
224
+ this_1 = this;
225
+ for (i = 0; i < codeActions.length; i++) {
226
+ state_1 = _loop_1(i);
227
+ if (typeof state_1 === "object")
228
+ return [2 /*return*/, state_1.value];
229
+ }
230
+ return [2 /*return*/, actions];
231
+ }
232
+ });
233
+ });
234
+ };
235
+ DiagnosticsAdapter.prototype.getOrCreateDebouncedValidation = function (model, languageId) {
236
+ var _this = this;
237
+ var modelUri = model.uri.toString();
238
+ if (!this._debouncedValidations[modelUri]) {
239
+ this._debouncedValidations[modelUri] = debounce(function (intervals) { return _this._doValidate(model, languageId, intervals); }, 500);
240
+ }
241
+ return this._debouncedValidations[modelUri];
242
+ };
243
+ DiagnosticsAdapter.prototype.dispose = function () {
244
+ this._disposables.forEach(function (d) { return d && d.dispose(); });
245
+ this._disposables = [];
246
+ };
247
+ DiagnosticsAdapter.prototype._doValidate = function (model, languageId, intervals) {
248
+ var _this = this;
249
+ if (model.isDisposed()) {
250
+ return;
251
+ }
252
+ var resource = model.uri;
253
+ var versionNumberBefore = model.getVersionId();
254
+ this._worker(resource)
255
+ .then(function (worker) {
256
+ return worker.doValidation(resource.toString(), intervals);
257
+ })
258
+ .then(function (diagnostics) {
259
+ var newModel = _this._monacoInstance.editor.getModel(resource);
260
+ var versionId = newModel.getVersionId();
261
+ if (versionId !== versionNumberBefore) {
262
+ return;
263
+ }
264
+ var markers = diagnostics.map(function (d) { return toDiagnostics(resource, d); });
265
+ var model = _this._monacoInstance.editor.getModel(resource);
266
+ var oldDecorations = model
267
+ .getAllDecorations()
268
+ .filter(function (decoration) { return decoration.options.className == 'squiggly-error'; })
269
+ .map(function (decoration) { return decoration.id; });
270
+ if (model && model.getLanguageId() === languageId) {
271
+ var syntaxErrorAsMarkDown = _this.defaults.languageSettings.syntaxErrorAsMarkDown;
272
+ if (!syntaxErrorAsMarkDown || !syntaxErrorAsMarkDown.enableSyntaxErrorAsMarkDown) {
273
+ // Remove previous syntax error decorations and set the new markers (for example, when disabling syntaxErrorAsMarkDown after it was enabled)
274
+ model.deltaDecorations(oldDecorations, []);
275
+ _this._monacoInstance.editor.setModelMarkers(model, languageId, markers);
276
+ }
277
+ else {
278
+ // Add custom popup for syntax error: icon, header and message as markdown
279
+ var header = syntaxErrorAsMarkDown.header ? "**".concat(syntaxErrorAsMarkDown.header, "** \n\n") : '';
280
+ var icon = syntaxErrorAsMarkDown.icon ? "![](".concat(syntaxErrorAsMarkDown.icon, ")") : '';
281
+ var popupErrorHoverHeaderMessage_1 = "".concat(icon, " ").concat(header);
282
+ var newDecorations = markers.map(function (marker) {
283
+ return {
284
+ range: {
285
+ startLineNumber: marker.startLineNumber,
286
+ startColumn: marker.startColumn,
287
+ endLineNumber: marker.endLineNumber,
288
+ endColumn: marker.endColumn,
289
+ },
290
+ options: {
291
+ hoverMessage: {
292
+ value: popupErrorHoverHeaderMessage_1 + marker.message,
293
+ },
294
+ className: 'squiggly-error',
295
+ zIndex: 100,
296
+ overviewRuler: {
297
+ // The color indication on the right ruler
298
+ color: 'rgb(255, 18, 18, 0.7)',
299
+ position: monaco.editor.OverviewRulerLane.Right,
300
+ },
301
+ minimap: {
302
+ color: 'rgb(255, 18, 18, 0.7)',
303
+ position: monaco.editor.MinimapPosition.Inline,
304
+ },
305
+ },
306
+ };
307
+ });
308
+ var oldMarkers = monaco.editor.getModelMarkers({
309
+ owner: languageId,
310
+ resource: resource,
311
+ });
312
+ if (oldMarkers && oldMarkers.length > 0) {
313
+ // In case there were previous markers, remove their decorations (for example, when enabling syntaxErrorAsMarkDown after it was disabled)
314
+ oldDecorations = [];
315
+ // Remove previous markers
316
+ _this._monacoInstance.editor.setModelMarkers(model, languageId, []);
317
+ }
318
+ // Remove previous syntax error decorations and set the new decorations
319
+ model.deltaDecorations(oldDecorations, newDecorations);
320
+ }
321
+ }
322
+ })
323
+ .then(undefined, function (err) {
324
+ console.error(err);
325
+ });
326
+ };
327
+ return DiagnosticsAdapter;
328
+ }());
329
+ export { DiagnosticsAdapter };
330
+ function changeEventToIntervals(e) {
331
+ return e.changes.map(function (change) { return ({
332
+ start: change.rangeOffset,
333
+ end: change.rangeOffset + change.text.length,
334
+ }); });
335
+ }
336
+ function toSeverity(lsSeverity) {
337
+ switch (lsSeverity) {
338
+ case ls.DiagnosticSeverity.Error:
339
+ return monaco.MarkerSeverity.Error;
340
+ case ls.DiagnosticSeverity.Warning:
341
+ return monaco.MarkerSeverity.Warning;
342
+ case ls.DiagnosticSeverity.Information:
343
+ return monaco.MarkerSeverity.Info;
344
+ case ls.DiagnosticSeverity.Hint:
345
+ return monaco.MarkerSeverity.Hint;
346
+ default:
347
+ return monaco.MarkerSeverity.Info;
348
+ }
349
+ }
350
+ function toDiagnostics(resource, diag) {
351
+ var code = typeof diag.code === 'number' ? String(diag.code) : diag.code;
352
+ return {
353
+ severity: toSeverity(diag.severity),
354
+ startLineNumber: diag.range.start.line + 1,
355
+ startColumn: diag.range.start.character + 1,
356
+ endLineNumber: diag.range.end.line + 1,
357
+ endColumn: diag.range.end.character + 1,
358
+ message: diag.message,
359
+ code: code,
360
+ source: diag.source,
361
+ };
362
+ }
363
+ // --- colorization ---
364
+ function fromIRange(range) {
365
+ if (!range) {
366
+ return undefined;
367
+ }
368
+ if (range instanceof monaco.Range) {
369
+ return { start: fromPosition(range.getStartPosition()), end: fromPosition(range.getEndPosition()) };
370
+ }
371
+ var startLineNumber = range.startLineNumber, startColumn = range.startColumn, endLineNumber = range.endLineNumber, endColumn = range.endColumn;
372
+ range = new monaco.Range(startLineNumber, startColumn, endLineNumber, endColumn);
373
+ }
374
+ /**
375
+ * Copy of Kusto.Language.Editor.ClassificationKind we don't have to depend on it in this file
376
+ */
377
+ var ClassificationKind = {
378
+ PlainText: 0,
379
+ Comment: 1,
380
+ Punctuation: 2,
381
+ Directive: 3,
382
+ Literal: 4,
383
+ StringLiteral: 5,
384
+ Type: 6,
385
+ Column: 7,
386
+ Table: 8,
387
+ Database: 9,
388
+ Function: 10,
389
+ Parameter: 11,
390
+ Variable: 12,
391
+ Identifier: 13,
392
+ ClientParameter: 14,
393
+ QueryParameter: 15,
394
+ ScalarOperator: 16,
395
+ MathOperator: 17,
396
+ QueryOperator: 18,
397
+ Command: 19,
398
+ Keyword: 20,
399
+ MaterializedView: 21,
400
+ SchemaMember: 22,
401
+ SignatureParameter: 23,
402
+ Option: 24,
403
+ };
404
+ var ClassificationKindNames = {};
405
+ for (var _i = 0, _a = Object.entries(ClassificationKind); _i < _a.length; _i++) {
406
+ var _b = _a[_i], key = _b[0], value = _b[1];
407
+ ClassificationKindNames[value] = key;
408
+ }
409
+ // commented here is the color definitions are were defined by v1 intellisense terminology:
410
+ // { token: 'comment', foreground: '008000' }, // CommentToken Green
411
+ // { token: 'variable.predefined', foreground: '800080' }, // CalculatedColumnToken Purple
412
+ // { token: 'function', foreground: '0000FF' }, // FunctionNameToken Blue
413
+ // { token: 'operator.sql', foreground: 'FF4500' }, // OperatorToken OrangeRed (now changed to darker color CC3700 because wasn't accessible)
414
+ // { token: 'string', foreground: 'B22222' }, // StringLiteralToken Firebrick
415
+ // { token: 'operator.scss', foreground: '0000FF' }, // SubOperatorToken Blue
416
+ // { token: 'variable', foreground: 'C71585' }, // TableColumnToken MediumVioletRed
417
+ // { token: 'variable.parameter', foreground: '9932CC' }, // TableToken DarkOrchid
418
+ // { token: '', foreground: '000000' }, // UnknownToken, PlainTextToken Black
419
+ // { token: 'type', foreground: '0000FF' }, // DataTypeToken Blue
420
+ // { token: 'tag', foreground: '0000FF' }, // ControlCommandToken Blue
421
+ // { token: 'annotation', foreground: '2B91AF' }, // QueryParametersToken FF2B91AF
422
+ // { token: 'keyword', foreground: '0000FF' }, // CslCommandToken, PluginToken Blue
423
+ // { token: 'number', foreground: '191970' }, // LetVariablesToken MidnightBlue
424
+ // { token: 'annotation', foreground: '9400D3' }, // ClientDirectiveToken DarkViolet
425
+ // { token: 'invalid', background: 'cd3131' },
426
+ var classificationToColorLight = {
427
+ Column: 'C71585',
428
+ Comment: '008000',
429
+ Database: 'C71585',
430
+ Function: '0000FF',
431
+ Identifier: '000000',
432
+ Keyword: '0000FF',
433
+ Literal: 'B22222',
434
+ ScalarOperator: '0000FF',
435
+ MaterializedView: 'C71585',
436
+ MathOperator: '000000',
437
+ Command: '0000FF',
438
+ Parameter: '2B91AF',
439
+ PlainText: '000000',
440
+ Punctuation: '000000',
441
+ QueryOperator: 'CC3700',
442
+ QueryParameter: 'CC3700',
443
+ StringLiteral: 'B22222',
444
+ Table: 'C71585',
445
+ Type: '0000FF',
446
+ Variable: '191970',
447
+ Directive: '9400D3',
448
+ ClientParameter: 'b5cea8',
449
+ SchemaMember: 'C71585',
450
+ SignatureParameter: '2B91AF',
451
+ Option: '000000',
452
+ };
453
+ var classificationToColorDark = {
454
+ Column: '4ec9b0',
455
+ Comment: '6A9B34',
456
+ Database: 'c586c0',
457
+ Function: 'dcdcaa',
458
+ Identifier: 'd4d4d4',
459
+ Keyword: '569cd6',
460
+ Literal: 'ce9178',
461
+ ScalarOperator: '569cd6',
462
+ MaterializedView: 'c586c0',
463
+ MathOperator: 'd4d4d4',
464
+ Command: 'd4d4d4',
465
+ Parameter: '2B91AF',
466
+ PlainText: 'd4d4d4',
467
+ Punctuation: 'd4d4d4',
468
+ QueryOperator: '9cdcfe',
469
+ QueryParameter: '9cdcfe',
470
+ StringLiteral: 'ce9178',
471
+ Table: 'c586c0',
472
+ Type: '569cd6',
473
+ Variable: 'd7ba7d',
474
+ Directive: 'b5cea8',
475
+ ClientParameter: 'b5cea8',
476
+ SchemaMember: '4ec9b0',
477
+ SignatureParameter: '2B91AF',
478
+ Option: 'd4d4d4',
479
+ };
480
+ var ColorizationAdapter = /** @class */ (function () {
481
+ function ColorizationAdapter(_monacoInstance, _languageId, _worker, defaults, onSchemaChange) {
482
+ var _this = this;
483
+ this._monacoInstance = _monacoInstance;
484
+ this._languageId = _languageId;
485
+ this._worker = _worker;
486
+ this._disposables = [];
487
+ this._contentListener = Object.create(null);
488
+ this._configurationListener = Object.create(null);
489
+ this._schemaListener = Object.create(null);
490
+ this.decorations = [];
491
+ injectCss();
492
+ var onModelAdd = function (model) {
493
+ var languageId = model.getLanguageId();
494
+ if (languageId !== _this._languageId) {
495
+ return;
496
+ }
497
+ var debouncedColorization = debounce(function (intervals) { return _this._doColorization(model, languageId, intervals); }, 500);
498
+ var handle;
499
+ _this._contentListener[model.uri.toString()] = model.onDidChangeContent(function (e) {
500
+ // Changes are represented as a range in doc before change, plus the text that it was replaced with.
501
+ // We are interested in the range _after_ the change (since that's what we need to colorize).
502
+ // following logic calculates that.
503
+ var intervalsToColorize = changeEventToIntervals(e);
504
+ debouncedColorization(intervalsToColorize);
505
+ });
506
+ _this._configurationListener[model.uri.toString()] = defaults.onDidChange(function () {
507
+ self.setTimeout(function () { return _this._doColorization(model, languageId, []); }, 0);
508
+ });
509
+ _this._schemaListener[model.uri.toString()] = onSchemaChange(function () {
510
+ self.setTimeout(function () { return _this._doColorization(model, languageId, []); }, 0);
511
+ });
512
+ };
513
+ var onModelRemoved = function (model) {
514
+ model.deltaDecorations(_this.decorations, []);
515
+ var uriStr = model.uri.toString();
516
+ var contentListener = _this._contentListener[uriStr];
517
+ if (contentListener) {
518
+ contentListener.dispose();
519
+ delete _this._contentListener[uriStr];
520
+ }
521
+ var configurationListener = _this._configurationListener[uriStr];
522
+ if (configurationListener) {
523
+ configurationListener.dispose();
524
+ delete _this._configurationListener[uriStr];
525
+ }
526
+ var schemaListener = _this._configurationListener[uriStr];
527
+ if (schemaListener) {
528
+ schemaListener.dispose();
529
+ delete _this._schemaListener[uriStr];
530
+ }
531
+ };
532
+ this._disposables.push(this._monacoInstance.editor.onDidCreateModel(onModelAdd));
533
+ this._disposables.push(this._monacoInstance.editor.onWillDisposeModel(onModelRemoved));
534
+ this._disposables.push(this._monacoInstance.editor.onDidChangeModelLanguage(function (event) {
535
+ onModelRemoved(event.model);
536
+ onModelAdd(event.model);
537
+ }));
538
+ this._disposables.push({
539
+ dispose: function () {
540
+ for (var key in _this._contentListener) {
541
+ _this._contentListener[key].dispose();
542
+ }
543
+ },
544
+ });
545
+ this._monacoInstance.editor.getModels().forEach(onModelAdd);
546
+ }
547
+ ColorizationAdapter.prototype.dispose = function () {
548
+ this._disposables.forEach(function (d) { return d && d.dispose(); });
549
+ this._disposables = [];
550
+ };
551
+ /**
552
+ * Return true if the range doesn't intersect any of the line ranges.
553
+ * @param range monaco.Range
554
+ * @param impactedLineRanges an array of line ranges
555
+ */
556
+ ColorizationAdapter.prototype._rangeDoesNotIntersectAny = function (range, impactedLineRanges) {
557
+ return impactedLineRanges.every(function (lineRange) {
558
+ return range.startLineNumber > lineRange.lastImpactedLine || range.endLineNumber < lineRange.firstImpactedLine;
559
+ });
560
+ };
561
+ ColorizationAdapter.prototype._doColorization = function (model, languageId, intervals) {
562
+ var _this = this;
563
+ if (model.isDisposed()) {
564
+ return;
565
+ }
566
+ var resource = model.uri;
567
+ var versionNumberBeforeColorization = model.getVersionId();
568
+ this._worker(resource)
569
+ .then(function (worker) {
570
+ return worker.doColorization(resource.toString(), intervals);
571
+ })
572
+ .then(function (colorizationRanges) {
573
+ var newModel = _this._monacoInstance.editor.getModel(model.uri);
574
+ var versionId = newModel.getVersionId();
575
+ // don't colorize an older version of the document.
576
+ if (versionId !== versionNumberBeforeColorization) {
577
+ return;
578
+ }
579
+ var decorationRanges = colorizationRanges.map(function (colorizationRange) {
580
+ var decorations = colorizationRange.classifications
581
+ .map(function (classification) { return toDecoration(model, classification); })
582
+ // The following line will prevent things that aren't going to be colorized anyway to get a CSS class.
583
+ // This will prevent the case where the non-semantic colorizer already figured out that a keyword needs
584
+ // to be colorized, but the outdated semantic colorizer still thinks it's a plain text and wants it colored
585
+ // in black.
586
+ .filter(function (d) {
587
+ return d.options.inlineClassName !== 'PlainText' && d.options.inlineClassName != 'Identifier';
588
+ });
589
+ var firstImpactedLine = model.getPositionAt(colorizationRange.absoluteStart).lineNumber;
590
+ var endPosition = model.getPositionAt(colorizationRange.absoluteEnd);
591
+ // A token that ends in the first column of the next line is not considered to be part of that line.
592
+ var lastImpactedLine = endPosition.column == 1 && endPosition.lineNumber > 1
593
+ ? endPosition.lineNumber - 1
594
+ : endPosition.lineNumber;
595
+ return { decorations: decorations, firstImpactedLine: firstImpactedLine, lastImpactedLine: lastImpactedLine };
596
+ });
597
+ // Compute the previous decorations we want to replace with the new ones.
598
+ var oldDecorations = decorationRanges
599
+ .map(function (range) {
600
+ return model
601
+ .getLinesDecorations(range.firstImpactedLine, range.lastImpactedLine)
602
+ .filter(function (d) { return classificationToColorLight[d.options.inlineClassName]; }) // Don't delete any other decorations
603
+ .map(function (d) { return d.id; });
604
+ })
605
+ .reduce(function (prev, curr) { return prev.concat(curr); }, []);
606
+ // Flatten decoration groups to an array of decorations
607
+ var newDecorations = decorationRanges.reduce(function (prev, next) { return prev.concat(next.decorations); }, []);
608
+ if (model && model.getLanguageId() === languageId) {
609
+ _this.decorations = model.deltaDecorations(oldDecorations, newDecorations);
610
+ }
611
+ })
612
+ .then(undefined, function (err) {
613
+ console.error(err);
614
+ });
615
+ };
616
+ return ColorizationAdapter;
617
+ }());
618
+ export { ColorizationAdapter };
619
+ /**
620
+ * Gets all keys of an enum (the string keys not the numeric values).
621
+ * @param e Enum type
622
+ */
623
+ function getEnumKeys(e) {
624
+ return Object.keys(e).filter(function (k) { return typeof e[k] === 'number'; });
625
+ }
626
+ /**
627
+ * Generates a mapping between ClassificationKind and color.
628
+ */
629
+ function getClassificationColorTriplets() {
630
+ var result = Object.keys(ClassificationKind).map(function (key) { return ({
631
+ classification: key,
632
+ colorLight: classificationToColorLight[key],
633
+ colorDark: classificationToColorDark[key],
634
+ }); });
635
+ return result;
636
+ }
637
+ /**
638
+ * Returns a string which is a css describing all tokens and their colors.
639
+ * looks a little bit something like this:
640
+ *
641
+ * .vs .Literal {color: '#000000';} .vs-dark .Literal {color: '#FFFFFF';}
642
+ * .vs .Comment {color: '#111111';} .vs-dark .Comment {color: '#EEEEEE';}
643
+ */
644
+ function getCssForClassification() {
645
+ var classificationColorTriplets = getClassificationColorTriplets();
646
+ var cssInnerHtml = classificationColorTriplets
647
+ .map(function (pair) {
648
+ return ".vs .".concat(pair.classification, " {color: #").concat(pair.colorLight, ";} .vs-dark .").concat(pair.classification, " {color: #").concat(pair.colorDark, ";}");
649
+ })
650
+ .join('\n');
651
+ return cssInnerHtml;
652
+ }
653
+ /**
654
+ * Inject a CSS sheet to the head of document, coloring kusto elements by classification.
655
+ * TODO: make idempotent
656
+ */
657
+ function injectCss() {
658
+ var container = document.getElementsByTagName('head')[0];
659
+ var style = document.createElement('style');
660
+ style.type = 'text/css';
661
+ style.media = 'screen';
662
+ container.appendChild(style);
663
+ ClassificationKind;
664
+ style.innerHTML = getCssForClassification();
665
+ }
666
+ function toDecoration(model, classification) {
667
+ var start = model.getPositionAt(classification.start);
668
+ var end = model.getPositionAt(classification.start + classification.length);
669
+ var range = new monaco.Range(start.lineNumber, start.column, end.lineNumber, end.column);
670
+ var inlineClassName = ClassificationKindNames[classification.kind];
671
+ return {
672
+ range: range,
673
+ options: {
674
+ inlineClassName: inlineClassName,
675
+ stickiness: monaco.editor.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
676
+ },
677
+ };
678
+ }
679
+ // --- completion ------
680
+ function fromPosition(position) {
681
+ if (!position) {
682
+ return void 0;
683
+ }
684
+ return { character: position.column - 1, line: position.lineNumber - 1 };
685
+ }
686
+ function fromRange(range) {
687
+ if (!range) {
688
+ return void 0;
689
+ }
690
+ return { start: fromPosition(range.getStartPosition()), end: fromPosition(range.getEndPosition()) };
691
+ }
692
+ function toRange(range) {
693
+ if (!range) {
694
+ return void 0;
695
+ }
696
+ return new monaco.Range(range.start.line + 1, range.start.character + 1, range.end.line + 1, range.end.character + 1);
697
+ }
698
+ function toCompletionItemKind(kind) {
699
+ var mItemKind = monaco.languages.CompletionItemKind;
700
+ switch (kind) {
701
+ case ls.CompletionItemKind.Text:
702
+ return mItemKind.Text;
703
+ case ls.CompletionItemKind.Method:
704
+ return mItemKind.Method;
705
+ case ls.CompletionItemKind.Function:
706
+ return mItemKind.Function;
707
+ case ls.CompletionItemKind.Constructor:
708
+ return mItemKind.Constructor;
709
+ case ls.CompletionItemKind.Field:
710
+ return mItemKind.Field;
711
+ case ls.CompletionItemKind.Variable:
712
+ return mItemKind.Variable;
713
+ case ls.CompletionItemKind.Class:
714
+ return mItemKind.Class;
715
+ case ls.CompletionItemKind.Interface:
716
+ return mItemKind.Interface;
717
+ case ls.CompletionItemKind.Module:
718
+ return mItemKind.Module;
719
+ case ls.CompletionItemKind.Property:
720
+ return mItemKind.Property;
721
+ case ls.CompletionItemKind.Unit:
722
+ return mItemKind.Unit;
723
+ case ls.CompletionItemKind.Value:
724
+ return mItemKind.Value;
725
+ case ls.CompletionItemKind.Enum:
726
+ return mItemKind.Enum;
727
+ case ls.CompletionItemKind.Keyword:
728
+ return mItemKind.Keyword;
729
+ case ls.CompletionItemKind.Snippet:
730
+ return mItemKind.Snippet;
731
+ case ls.CompletionItemKind.Color:
732
+ return mItemKind.Color;
733
+ case ls.CompletionItemKind.File:
734
+ return mItemKind.File;
735
+ case ls.CompletionItemKind.Reference:
736
+ return mItemKind.Reference;
737
+ }
738
+ return mItemKind.Property;
739
+ }
740
+ function toTextEdit(textEdit) {
741
+ if (!textEdit) {
742
+ return void 0;
743
+ }
744
+ return {
745
+ range: toRange(textEdit.range),
746
+ text: textEdit.newText,
747
+ };
748
+ }
749
+ var DEFAULT_DOCS_BASE_URL = 'https://learn.microsoft.com/azure/data-explorer/kusto/query';
750
+ var CompletionAdapter = /** @class */ (function () {
751
+ function CompletionAdapter(_worker, languageSettings) {
752
+ this._worker = _worker;
753
+ this.languageSettings = languageSettings;
754
+ }
755
+ Object.defineProperty(CompletionAdapter.prototype, "triggerCharacters", {
756
+ get: function () {
757
+ return [' '];
758
+ },
759
+ enumerable: false,
760
+ configurable: true
761
+ });
762
+ CompletionAdapter.prototype.provideCompletionItems = function (model, position, context, token) {
763
+ var _this = this;
764
+ var wordInfo = model.getWordUntilPosition(position);
765
+ var wordRange = new monaco.Range(position.lineNumber, wordInfo.startColumn, position.lineNumber, wordInfo.endColumn);
766
+ var resource = model.uri;
767
+ var onDidProvideCompletionItems = this.languageSettings.onDidProvideCompletionItems;
768
+ return this._worker(resource)
769
+ .then(function (worker) {
770
+ return worker.doComplete(resource.toString(), fromPosition(position));
771
+ })
772
+ .then(function (info) { return (onDidProvideCompletionItems ? onDidProvideCompletionItems(info) : info); })
773
+ .then(function (info) {
774
+ if (!info) {
775
+ return;
776
+ }
777
+ var items = info.items.map(function (entry) {
778
+ var _a;
779
+ var item = {
780
+ label: entry.label,
781
+ insertText: entry.insertText,
782
+ sortText: entry.sortText,
783
+ filterText: entry.filterText,
784
+ // TODO: Is this cast safe?
785
+ documentation: _this.formatDocLink((_a = entry.documentation) === null || _a === void 0 ? void 0 : _a.value),
786
+ detail: entry.detail,
787
+ range: wordRange,
788
+ kind: toCompletionItemKind(entry.kind),
789
+ };
790
+ if (entry.textEdit) {
791
+ // TODO: Where is the "range" property coming from?
792
+ item.range = toRange(entry.textEdit.range);
793
+ item.insertText = entry.textEdit.newText;
794
+ }
795
+ if (entry.insertTextFormat === ls.InsertTextFormat.Snippet) {
796
+ item.insertTextRules = monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet;
797
+ }
798
+ return item;
799
+ });
800
+ return {
801
+ isIncomplete: info.isIncomplete,
802
+ suggestions: items,
803
+ };
804
+ });
805
+ };
806
+ CompletionAdapter.prototype.formatDocLink = function (docString) {
807
+ // If the docString is empty, we want to return undefined to prevent an empty documentation popup.
808
+ if (!docString) {
809
+ return undefined;
810
+ }
811
+ var _a = this.languageSettings, _b = _a.documentationBaseUrl, documentationBaseUrl = _b === void 0 ? DEFAULT_DOCS_BASE_URL : _b, documentationSuffix = _a.documentationSuffix;
812
+ var urisProxy = new Proxy({}, {
813
+ get: function (_target, prop, _receiver) {
814
+ // The link comes with a postfix of ".md" that we want to remove
815
+ var url = prop.toString().replace('.md', '');
816
+ // Sometimes we get the link as a full URL. For example in the main doc link of the item
817
+ if (!url.startsWith('https')) {
818
+ url = "".concat(documentationBaseUrl, "/").concat(url);
819
+ }
820
+ var monacoUri = monaco.Uri.parse(url);
821
+ if (documentationSuffix) {
822
+ // We need to override the toString method to add the suffix, otherwise it gets encoded and page doesn't open
823
+ monacoUri.toString = function () { return url + documentationSuffix; };
824
+ }
825
+ return monacoUri;
826
+ },
827
+ });
828
+ return { value: docString, isTrusted: true, uris: urisProxy };
829
+ };
830
+ return CompletionAdapter;
831
+ }());
832
+ export { CompletionAdapter };
833
+ function isMarkupContent(thing) {
834
+ return thing && typeof thing === 'object' && typeof thing.kind === 'string';
835
+ }
836
+ function toMarkdownString(entry) {
837
+ if (typeof entry === 'string') {
838
+ return {
839
+ value: entry,
840
+ };
841
+ }
842
+ if (isMarkupContent(entry)) {
843
+ if (entry.kind === 'plaintext') {
844
+ return {
845
+ value: entry.value.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&'),
846
+ };
847
+ }
848
+ return {
849
+ value: entry.value,
850
+ };
851
+ }
852
+ return { value: '```' + entry.value + '\n' + entry.value + '\n```\n' };
853
+ }
854
+ function toMarkedStringArray(contents) {
855
+ if (!contents) {
856
+ return void 0;
857
+ }
858
+ if (Array.isArray(contents)) {
859
+ return contents.map(toMarkdownString);
860
+ }
861
+ return [toMarkdownString(contents)];
862
+ }
863
+ // --- definition ------
864
+ function toLocation(location) {
865
+ return {
866
+ uri: monaco.Uri.parse(location.uri),
867
+ range: toRange(location.range),
868
+ };
869
+ }
870
+ var DefinitionAdapter = /** @class */ (function () {
871
+ function DefinitionAdapter(_worker) {
872
+ this._worker = _worker;
873
+ }
874
+ DefinitionAdapter.prototype.provideDefinition = function (model, position, token) {
875
+ var resource = model.uri;
876
+ return this._worker(resource)
877
+ .then(function (worker) {
878
+ return worker.findDefinition(resource.toString(), fromPosition(position));
879
+ })
880
+ .then(function (definition) {
881
+ if (!definition || definition.length == 0) {
882
+ return;
883
+ }
884
+ return [toLocation(definition[0])];
885
+ });
886
+ };
887
+ return DefinitionAdapter;
888
+ }());
889
+ export { DefinitionAdapter };
890
+ // --- references ------
891
+ var ReferenceAdapter = /** @class */ (function () {
892
+ function ReferenceAdapter(_worker) {
893
+ this._worker = _worker;
894
+ }
895
+ ReferenceAdapter.prototype.provideReferences = function (model, position, context, token) {
896
+ var resource = model.uri;
897
+ return this._worker(resource)
898
+ .then(function (worker) {
899
+ return worker.findReferences(resource.toString(), fromPosition(position));
900
+ })
901
+ .then(function (entries) {
902
+ if (!entries) {
903
+ return;
904
+ }
905
+ return entries.map(toLocation);
906
+ });
907
+ };
908
+ return ReferenceAdapter;
909
+ }());
910
+ export { ReferenceAdapter };
911
+ // --- rename ------
912
+ function toWorkspaceEdit(edit) {
913
+ if (!edit || !edit.changes) {
914
+ return void 0;
915
+ }
916
+ var resourceEdits = [];
917
+ for (var uri in edit.changes) {
918
+ var _uri = monaco.Uri.parse(uri);
919
+ for (var _i = 0, _a = edit.changes[uri]; _i < _a.length; _i++) {
920
+ var e = _a[_i];
921
+ resourceEdits.push({
922
+ resource: _uri,
923
+ textEdit: {
924
+ range: toRange(e.range),
925
+ text: e.newText,
926
+ },
927
+ versionId: undefined,
928
+ });
929
+ }
930
+ }
931
+ return {
932
+ edits: resourceEdits,
933
+ };
934
+ }
935
+ var RenameAdapter = /** @class */ (function () {
936
+ function RenameAdapter(_worker) {
937
+ this._worker = _worker;
938
+ }
939
+ RenameAdapter.prototype.provideRenameEdits = function (model, position, newName, token) {
940
+ var resource = model.uri;
941
+ return this._worker(resource)
942
+ .then(function (worker) {
943
+ return worker.doRename(resource.toString(), fromPosition(position), newName);
944
+ })
945
+ .then(function (edit) {
946
+ return toWorkspaceEdit(edit);
947
+ });
948
+ };
949
+ return RenameAdapter;
950
+ }());
951
+ export { RenameAdapter };
952
+ // --- document symbols ------
953
+ function toSymbolKind(kind) {
954
+ var mKind = monaco.languages.SymbolKind;
955
+ switch (kind) {
956
+ case ls.SymbolKind.File:
957
+ return mKind.Array;
958
+ case ls.SymbolKind.Module:
959
+ return mKind.Module;
960
+ case ls.SymbolKind.Namespace:
961
+ return mKind.Namespace;
962
+ case ls.SymbolKind.Package:
963
+ return mKind.Package;
964
+ case ls.SymbolKind.Class:
965
+ return mKind.Class;
966
+ case ls.SymbolKind.Method:
967
+ return mKind.Method;
968
+ case ls.SymbolKind.Property:
969
+ return mKind.Property;
970
+ case ls.SymbolKind.Field:
971
+ return mKind.Field;
972
+ case ls.SymbolKind.Constructor:
973
+ return mKind.Constructor;
974
+ case ls.SymbolKind.Enum:
975
+ return mKind.Enum;
976
+ case ls.SymbolKind.Interface:
977
+ return mKind.Interface;
978
+ case ls.SymbolKind.Function:
979
+ return mKind.Function;
980
+ case ls.SymbolKind.Variable:
981
+ return mKind.Variable;
982
+ case ls.SymbolKind.Constant:
983
+ return mKind.Constant;
984
+ case ls.SymbolKind.String:
985
+ return mKind.String;
986
+ case ls.SymbolKind.Number:
987
+ return mKind.Number;
988
+ case ls.SymbolKind.Boolean:
989
+ return mKind.Boolean;
990
+ case ls.SymbolKind.Array:
991
+ return mKind.Array;
992
+ }
993
+ return mKind.Function;
994
+ }
995
+ // --- formatting -----
996
+ var DocumentFormatAdapter = /** @class */ (function () {
997
+ function DocumentFormatAdapter(_worker) {
998
+ this._worker = _worker;
999
+ }
1000
+ DocumentFormatAdapter.prototype.provideDocumentFormattingEdits = function (model, options, token) {
1001
+ var resource = model.uri;
1002
+ return this._worker(resource).then(function (worker) {
1003
+ return worker.doDocumentFormat(resource.toString()).then(function (edits) { return edits.map(function (edit) { return toTextEdit(edit); }); });
1004
+ });
1005
+ };
1006
+ return DocumentFormatAdapter;
1007
+ }());
1008
+ export { DocumentFormatAdapter };
1009
+ var FormatAdapter = /** @class */ (function () {
1010
+ function FormatAdapter(_worker) {
1011
+ this._worker = _worker;
1012
+ }
1013
+ FormatAdapter.prototype.provideDocumentRangeFormattingEdits = function (model, range, options, token) {
1014
+ var resource = model.uri;
1015
+ return this._worker(resource).then(function (worker) {
1016
+ return worker
1017
+ .doRangeFormat(resource.toString(), fromRange(range))
1018
+ .then(function (edits) { return edits.map(function (edit) { return toTextEdit(edit); }); });
1019
+ });
1020
+ };
1021
+ return FormatAdapter;
1022
+ }());
1023
+ export { FormatAdapter };
1024
+ // --- Folding ---
1025
+ var FoldingAdapter = /** @class */ (function () {
1026
+ function FoldingAdapter(_worker) {
1027
+ this._worker = _worker;
1028
+ }
1029
+ FoldingAdapter.prototype.provideFoldingRanges = function (model, context, token) {
1030
+ var resource = model.uri;
1031
+ return this._worker(resource).then(function (worker) {
1032
+ return worker
1033
+ .doFolding(resource.toString())
1034
+ .then(function (foldingRanges) {
1035
+ return foldingRanges.map(function (range) { return toFoldingRange(range); });
1036
+ });
1037
+ });
1038
+ };
1039
+ return FoldingAdapter;
1040
+ }());
1041
+ export { FoldingAdapter };
1042
+ function toFoldingRange(range) {
1043
+ return {
1044
+ start: range.startLine + 1,
1045
+ end: range.endLine + 1,
1046
+ kind: monaco.languages.FoldingRangeKind.Region,
1047
+ };
1048
+ }
1049
+ // --- hover ------
1050
+ var HoverAdapter = /** @class */ (function () {
1051
+ function HoverAdapter(_worker) {
1052
+ this._worker = _worker;
1053
+ }
1054
+ HoverAdapter.prototype.provideHover = function (model, position, token) {
1055
+ var resource = model.uri;
1056
+ return this._worker(resource)
1057
+ .then(function (worker) {
1058
+ return worker.doHover(resource.toString(), fromPosition(position));
1059
+ })
1060
+ .then(function (info) {
1061
+ if (!info) {
1062
+ return;
1063
+ }
1064
+ return {
1065
+ range: toRange(info.range),
1066
+ contents: toMarkedStringArray(info.contents),
1067
+ };
1068
+ });
1069
+ };
1070
+ return HoverAdapter;
1071
+ }());
1072
+ export { HoverAdapter };