@kusto/monaco-kusto 11.4.0 → 12.0.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.
Files changed (48) hide show
  1. package/README.md +25 -1
  2. package/package.json +3 -1
  3. package/release/dev/kustoMode-d3f9e09a.js +1818 -0
  4. package/release/dev/kustoMode.js +4 -2040
  5. package/release/dev/kustoWorker.js +49 -90
  6. package/release/dev/{main-1587ba64.js → main-f36cb42f.js} +2 -2
  7. package/release/dev/monaco.contribution.js +254 -214
  8. package/release/dev/{schema-a5230652.js → schema-077630e6.js} +13 -2
  9. package/release/esm/extendedGlobalApi/getRangeHtml.d.ts +2 -0
  10. package/release/esm/extendedGlobalApi/getRangeHtml.js +11 -0
  11. package/release/esm/extendedGlobalApi/index.d.ts +1 -0
  12. package/release/esm/extendedGlobalApi/index.js +1 -0
  13. package/release/esm/globals.d.ts +1 -0
  14. package/release/esm/globals.js +1 -0
  15. package/release/esm/kusto.worker.js +39 -91
  16. package/release/esm/kustoMode-349f5467.js +957 -0
  17. package/release/esm/kustoMode.d.ts +4 -8
  18. package/release/esm/kustoMode.js +94 -104
  19. package/release/esm/kustoWorker.d.ts +2 -5
  20. package/release/esm/kustoWorker.js +2 -5
  21. package/release/esm/languageFeatures.d.ts +1 -14
  22. package/release/esm/languageFeatures.js +0 -299
  23. package/release/esm/languageServiceManager/kustoLanguageService.d.ts +2 -4
  24. package/release/esm/languageServiceManager/kustoLanguageService.js +58 -71
  25. package/release/esm/languageServiceManager/schema.d.ts +2 -2
  26. package/release/esm/languageServiceManager/settings.d.ts +0 -2
  27. package/release/esm/monaco.contribution.d.ts +1 -6
  28. package/release/esm/monaco.contribution.js +64 -88
  29. package/release/esm/{schema-c006895b.js → schema-b8f0ba9b.js} +12 -2
  30. package/release/esm/syntaxHighlighting/SemanticTokensProvider.d.ts +18 -0
  31. package/release/esm/syntaxHighlighting/SemanticTokensProvider.js +78 -0
  32. package/release/esm/syntaxHighlighting/kustoMonarchLanguageDefinition.d.ts +2 -0
  33. package/release/esm/syntaxHighlighting/kustoMonarchLanguageDefinition.js +401 -0
  34. package/release/esm/syntaxHighlighting/semanticTokensProviderRegistrar.d.ts +6 -0
  35. package/release/esm/syntaxHighlighting/semanticTokensProviderRegistrar.js +23 -0
  36. package/release/esm/syntaxHighlighting/themes.d.ts +11 -0
  37. package/release/esm/syntaxHighlighting/themes.js +103 -0
  38. package/release/esm/syntaxHighlighting/types.d.ts +41 -0
  39. package/release/esm/syntaxHighlighting/types.js +55 -0
  40. package/release/min/kustoMode-2dd4a01e.js +7 -0
  41. package/release/min/kustoMode.js +2 -2
  42. package/release/min/kustoWorker.js +4 -4
  43. package/release/min/{main-75aa3e71.js → main-86d6c837.js} +2 -2
  44. package/release/min/monaco.contribution.js +2 -2
  45. package/release/min/schema-a60c216c.js +7 -0
  46. package/release/esm/languageServiceManager/kustoMonarchLanguageDefinition.d.ts +0 -2
  47. package/release/esm/languageServiceManager/kustoMonarchLanguageDefinition.js +0 -211
  48. package/release/min/schema-192b3175.js +0 -7
@@ -1,2051 +1,15 @@
1
1
  /*!-----------------------------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * monaco-kusto version: 11.4.0(7572339ea10d5d0fdd55c4a2b813f3663acab903)
3
+ * monaco-kusto version: 12.0.1(56b90ce0fd31e7d6792f5098d1e8204274966b6e)
4
4
  * Released under the MIT license
5
5
  * https://https://github.com/Azure/monaco-kusto/blob/master/README.md
6
6
  *-----------------------------------------------------------------------------*/
7
7
 
8
- define('vs/language/kusto/kustoMode', ['exports', 'vs/editor/editor.main', './main-1587ba64'], (function (exports, monaco, main) { 'use strict';
8
+ define('vs/language/kusto/kustoMode', ['exports', 'vs/editor/editor.main', './kustoMode-d3f9e09a', './main-f36cb42f'], (function (exports, monaco, kustoMode, main) { 'use strict';
9
9
 
10
- function _interopNamespaceDefault(e) {
11
- var n = Object.create(null);
12
- if (e) {
13
- Object.keys(e).forEach(function (k) {
14
- if (k !== 'default') {
15
- var d = Object.getOwnPropertyDescriptor(e, k);
16
- Object.defineProperty(n, k, d.get ? d : {
17
- enumerable: true,
18
- get: function () { return e[k]; }
19
- });
20
- }
21
- });
22
- }
23
- n.default = e;
24
- return Object.freeze(n);
25
- }
26
10
 
27
- var monaco__namespace = /*#__PURE__*/_interopNamespaceDefault(monaco);
28
11
 
29
- var _excluded = ["onDidProvideCompletionItems"];
30
- function _typeof$7(o) { "@babel/helpers - typeof"; return _typeof$7 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof$7(o); }
31
- function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
32
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
33
- function _classCallCheck$1(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
34
- function _defineProperties$1(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey$2(o.key), o); } }
35
- function _createClass$1(e, r, t) { return r && _defineProperties$1(e.prototype, r), t && _defineProperties$1(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
36
- function _toPropertyKey$2(t) { var i = _toPrimitive$2(t, "string"); return "symbol" == _typeof$7(i) ? i : i + ""; }
37
- function _toPrimitive$2(t, r) { if ("object" != _typeof$7(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof$7(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
38
- var WorkerManager = /*#__PURE__*/function () {
39
- function WorkerManager(_monacoInstance, defaults) {
40
- var _this = this;
41
- _classCallCheck$1(this, WorkerManager);
42
- this._monacoInstance = _monacoInstance;
43
- this._defaults = defaults;
44
- this._worker = null;
45
- this._idleCheckInterval = self.setInterval(function () {
46
- return _this._checkIfIdle();
47
- }, 30 * 1000);
48
- this._lastUsedTime = 0;
49
- this._configChangeListener = this._defaults.onDidChange(function () {
50
- return _this._saveStateAndStopWorker();
51
- });
52
- }
53
- return _createClass$1(WorkerManager, [{
54
- key: "_stopWorker",
55
- value: function _stopWorker() {
56
- if (this._worker) {
57
- this._worker.dispose();
58
- this._worker = null;
59
- }
60
- this._client = null;
61
- }
62
- }, {
63
- key: "_saveStateAndStopWorker",
64
- value: function _saveStateAndStopWorker() {
65
- var _this2 = this;
66
- if (!this._worker) {
67
- return;
68
- }
69
- this._worker.getProxy().then(function (proxy) {
70
- proxy.getSchema().then(function (schema) {
71
- _this2._storedState = {
72
- schema: schema
73
- };
74
- _this2._stopWorker();
75
- });
76
- });
77
- }
78
- }, {
79
- key: "dispose",
80
- value: function dispose() {
81
- clearInterval(this._idleCheckInterval);
82
- this._configChangeListener.dispose();
83
- this._stopWorker();
84
- }
85
- }, {
86
- key: "_checkIfIdle",
87
- value: function _checkIfIdle() {
88
- if (!this._worker) {
89
- return;
90
- }
91
- var maxIdleTime = this._defaults.getWorkerMaxIdleTime();
92
- var timePassedSinceLastUsed = Date.now() - this._lastUsedTime;
93
- if (maxIdleTime > 0 && timePassedSinceLastUsed > maxIdleTime) {
94
- this._saveStateAndStopWorker();
95
- }
96
- }
97
- }, {
98
- key: "_getClient",
99
- value: function _getClient() {
100
- var _this3 = this;
101
- this._lastUsedTime = Date.now();
102
-
103
- // Since onDidProvideCompletionItems is not used in web worker, and since functions cannot be trivially serialized (throws exception unable to clone), We remove it here.
104
- var _this$_defaults$langu = this._defaults.languageSettings;
105
- _this$_defaults$langu.onDidProvideCompletionItems;
106
- var languageSettings = _objectWithoutProperties(_this$_defaults$langu, _excluded);
107
- if (!this._client) {
108
- this._worker = this._monacoInstance.editor.createWebWorker({
109
- // module that exports the create() method and returns a `KustoWorker` instance
110
- moduleId: 'vs/language/kusto/kustoWorker',
111
- label: 'kusto',
112
- // passed in to the create() method
113
- createData: {
114
- languageSettings: languageSettings,
115
- languageId: 'kusto'
116
- }
117
- });
118
- this._client = this._worker.getProxy().then(function (proxy) {
119
- // push state we held onto before killing the client.
120
- if (_this3._storedState) {
121
- return proxy.setSchema(_this3._storedState.schema).then(function () {
122
- return proxy;
123
- });
124
- } else {
125
- return proxy;
126
- }
127
- });
128
- }
129
- return this._client;
130
- }
131
- }, {
132
- key: "getLanguageServiceWorker",
133
- value: function getLanguageServiceWorker() {
134
- var _this4 = this;
135
- for (var _len = arguments.length, resources = new Array(_len), _key = 0; _key < _len; _key++) {
136
- resources[_key] = arguments[_key];
137
- }
138
- var _client;
139
- return this._getClient().then(function (client) {
140
- _client = client;
141
- }).then(function (_) {
142
- return _this4._worker.withSyncedResources(resources);
143
- }).then(function (_) {
144
- return _client;
145
- });
146
- }
147
- }]);
148
- }();
149
-
150
- var KustoLanguageDefinition = {
151
- name: 'kusto',
152
- mimeTypes: ['text/kusto'],
153
- displayName: 'Kusto',
154
- defaultToken: 'invalid',
155
- brackets: [['[', ']', 'delimiter.square'], ['(', ')', 'delimiter.parenthesis']],
156
- // types are wrong
157
- wordDefinition: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
158
- // .slice() call is for creating a shallow copy of the array since bridge.net shoves a $type property on the array which monaco doesn't like.
159
- // Kusto.Data.IntelliSense.CslCommandParser.PromotedOperatorCommandTokens.slice(0),
160
- promotedOperatorCommandTokens: ['where', 'count', 'extend', 'join', 'limit', 'order', 'project', 'project-away', 'project-rename', 'project-reorder', 'project-keep', 'render', 'sort', 'summarize', 'distinct', 'take', 'top', 'top-nested', 'top-hitters', 'union', 'mv-expand', 'mv-apply', 'reduce', 'evaluate', 'parse', 'parse-where', 'parse-kv', 'sample', 'sample-distinct', 'make-series', 'getschema', 'serialize', 'invoke', 'as', 'scan'],
161
- // Kusto.Data.IntelliSense.CslCommandParser.OperatorCommandTokens.slice(0),
162
- operatorCommandTokens: ['filter', 'fork', 'facet', 'range', 'consume', 'find', 'search', 'print', 'partition', 'lookup', 'where', 'count', 'extend', 'join', 'limit', 'order', 'project', 'project-away', 'project-rename', 'project-reorder', 'project-keep', 'render', 'sort', 'summarize', 'distinct', 'take', 'top', 'top-nested', 'top-hitters', 'union', 'mv-expand', 'mv-apply', 'reduce', 'evaluate', 'parse', 'parse-where', 'parse-kv', 'sample', 'sample-distinct', 'make-series', 'getschema', 'serialize', 'invoke', 'as', 'scan'],
163
- keywords: ['by', 'on', 'contains', 'notcontains', 'containscs', 'notcontainscs', 'startswith', 'has', 'matches', 'regex', 'true', 'false', 'and', 'or', 'typeof', 'int', 'string', 'date', 'datetime', 'time', 'long', 'real', '​boolean', 'bool'],
164
- operators: ['+', '-', '*', '/', '>', '<', '==', '<>', '<=', '>=', '~', '!~'],
165
- builtinFunctions: ['countof', 'bin', 'extentid', 'extract', 'extractjson', 'floor', 'iif', 'isnull', 'isnotnull', 'notnull', 'isempty', 'isnotempty', 'notempty', 'now', 're2', 'strcat', 'strlen', 'toupper', 'tostring', 'count', 'cnt', 'sum', 'min', 'max', 'avg'],
166
- tokenizer: {
167
- root: [{
168
- include: '@whitespace'
169
- }, {
170
- include: '@numbers'
171
- }, {
172
- include: '@strings'
173
- }, {
174
- include: '@dqstrings'
175
- }, {
176
- include: '@literals'
177
- }, {
178
- include: '@comments'
179
- }, [/[;,.]/, 'delimiter'], [/[()\[\]]/, '@brackets'], [/[<>=!%&+\-*/|~^]/, 'operator'], [/[\w@#\-$]+/, {
180
- cases: {
181
- '@keywords': 'keyword',
182
- '@promotedOperatorCommandTokens': 'operator.sql',
183
- '@operatorCommandTokens': 'keyword',
184
- '@operators': 'operator',
185
- '@builtinFunctions': 'predefined',
186
- '@default': 'identifier'
187
- }
188
- }]],
189
- whitespace: [[/\s+/, 'white']],
190
- comments: [['\\/\\/+.*', 'comment']],
191
- numbers: [[/0[xX][0-9a-fA-F]*/, 'number'], [/[$][+-]*\d*(\.\d*)?/, 'number'], [/((\d+(\.\d*)?)|(\.\d+))([eE][\-+]?\d+)?/, 'number']],
192
- strings: [[/H'/, {
193
- token: 'string.quote',
194
- bracket: '@open',
195
- next: '@string'
196
- }], [/h'/, {
197
- token: 'string.quote',
198
- bracket: '@open',
199
- next: '@string'
200
- }], [/'/, {
201
- token: 'string.quote',
202
- bracket: '@open',
203
- next: '@string'
204
- }]],
205
- string: [[/[^']+/, 'string'], [/''/, 'string'], [/'/, {
206
- token: 'string.quote',
207
- bracket: '@close',
208
- next: '@pop'
209
- }]],
210
- dqstrings: [[/H"/, {
211
- token: 'string.quote',
212
- bracket: '@open',
213
- next: '@dqstring'
214
- }], [/h"/, {
215
- token: 'string.quote',
216
- bracket: '@open',
217
- next: '@dqstring'
218
- }], [/"/, {
219
- token: 'string.quote',
220
- bracket: '@open',
221
- next: '@dqstring'
222
- }]],
223
- dqstring: [[/[^"]+/, 'string'], [/""/, 'string'], [/"/, {
224
- token: 'string.quote',
225
- bracket: '@close',
226
- next: '@pop'
227
- }]],
228
- literals: [[/datetime\(\d{4}-\d{2}-\d{2}(\s+\d{2}:\d{2}(:\d{2}(\.\d{0,3})?)?)?\)/, 'number'], [/time\((\d+(s(ec(onds?)?)?|m(in(utes?)?)?|h(ours?)?|d(ays?)?)|(\s*(('[^']+')|("[^"]+"))\s*))\)/, 'number'], [/guid\([\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}\)/, 'number'], [/typeof\((int|string|date|datetime|time|long|real|boolean|bool)\)/, 'number']]
229
- }
230
- };
231
-
232
- function _typeof$6(o) { "@babel/helpers - typeof"; return _typeof$6 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof$6(o); }
233
- /**
234
- * Checks if `value` is the
235
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
236
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
237
- *
238
- * @static
239
- * @memberOf _
240
- * @since 0.1.0
241
- * @category Lang
242
- * @param {*} value The value to check.
243
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
244
- * @example
245
- *
246
- * _.isObject({});
247
- * // => true
248
- *
249
- * _.isObject([1, 2, 3]);
250
- * // => true
251
- *
252
- * _.isObject(_.noop);
253
- * // => true
254
- *
255
- * _.isObject(null);
256
- * // => false
257
- */
258
- function isObject(value) {
259
- var type = _typeof$6(value);
260
- return value != null && (type == 'object' || type == 'function');
261
- }
262
-
263
- function _typeof$5(o) { "@babel/helpers - typeof"; return _typeof$5 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof$5(o); }
264
- /** Detect free variable `global` from Node.js. */
265
- var freeGlobal = (typeof global === "undefined" ? "undefined" : _typeof$5(global)) == 'object' && global && global.Object === Object && global;
266
- var freeGlobal$1 = freeGlobal;
267
-
268
- function _typeof$4(o) { "@babel/helpers - typeof"; return _typeof$4 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof$4(o); }
269
-
270
- /** Detect free variable `self`. */
271
- var freeSelf = (typeof self === "undefined" ? "undefined" : _typeof$4(self)) == 'object' && self && self.Object === Object && self;
272
-
273
- /** Used as a reference to the global object. */
274
- var root = freeGlobal$1 || freeSelf || Function('return this')();
275
- var root$1 = root;
276
-
277
- /**
278
- * Gets the timestamp of the number of milliseconds that have elapsed since
279
- * the Unix epoch (1 January 1970 00:00:00 UTC).
280
- *
281
- * @static
282
- * @memberOf _
283
- * @since 2.4.0
284
- * @category Date
285
- * @returns {number} Returns the timestamp.
286
- * @example
287
- *
288
- * _.defer(function(stamp) {
289
- * console.log(_.now() - stamp);
290
- * }, _.now());
291
- * // => Logs the number of milliseconds it took for the deferred invocation.
292
- */
293
- var now = function now() {
294
- return root$1.Date.now();
295
- };
296
- var now$1 = now;
297
-
298
- /** Used to match a single whitespace character. */
299
- var reWhitespace = /\s/;
300
-
301
- /**
302
- * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
303
- * character of `string`.
304
- *
305
- * @private
306
- * @param {string} string The string to inspect.
307
- * @returns {number} Returns the index of the last non-whitespace character.
308
- */
309
- function trimmedEndIndex(string) {
310
- var index = string.length;
311
- while (index-- && reWhitespace.test(string.charAt(index))) {}
312
- return index;
313
- }
314
-
315
- /** Used to match leading whitespace. */
316
- var reTrimStart = /^\s+/;
317
-
318
- /**
319
- * The base implementation of `_.trim`.
320
- *
321
- * @private
322
- * @param {string} string The string to trim.
323
- * @returns {string} Returns the trimmed string.
324
- */
325
- function baseTrim(string) {
326
- return string ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '') : string;
327
- }
328
-
329
- /** Built-in value references. */
330
- var _Symbol = root$1.Symbol;
331
- var _Symbol$1 = _Symbol;
332
-
333
- /** Used for built-in method references. */
334
- var objectProto$1 = Object.prototype;
335
-
336
- /** Used to check objects for own properties. */
337
- var hasOwnProperty = objectProto$1.hasOwnProperty;
338
-
339
- /**
340
- * Used to resolve the
341
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
342
- * of values.
343
- */
344
- var nativeObjectToString$1 = objectProto$1.toString;
345
-
346
- /** Built-in value references. */
347
- var symToStringTag$1 = _Symbol$1 ? _Symbol$1.toStringTag : undefined;
348
-
349
- /**
350
- * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
351
- *
352
- * @private
353
- * @param {*} value The value to query.
354
- * @returns {string} Returns the raw `toStringTag`.
355
- */
356
- function getRawTag(value) {
357
- var isOwn = hasOwnProperty.call(value, symToStringTag$1),
358
- tag = value[symToStringTag$1];
359
- try {
360
- value[symToStringTag$1] = undefined;
361
- var unmasked = true;
362
- } catch (e) {}
363
- var result = nativeObjectToString$1.call(value);
364
- if (unmasked) {
365
- if (isOwn) {
366
- value[symToStringTag$1] = tag;
367
- } else {
368
- delete value[symToStringTag$1];
369
- }
370
- }
371
- return result;
372
- }
373
-
374
- /** Used for built-in method references. */
375
- var objectProto = Object.prototype;
376
-
377
- /**
378
- * Used to resolve the
379
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
380
- * of values.
381
- */
382
- var nativeObjectToString = objectProto.toString;
383
-
384
- /**
385
- * Converts `value` to a string using `Object.prototype.toString`.
386
- *
387
- * @private
388
- * @param {*} value The value to convert.
389
- * @returns {string} Returns the converted string.
390
- */
391
- function objectToString(value) {
392
- return nativeObjectToString.call(value);
393
- }
394
-
395
- /** `Object#toString` result references. */
396
- var nullTag = '[object Null]',
397
- undefinedTag = '[object Undefined]';
398
-
399
- /** Built-in value references. */
400
- var symToStringTag = _Symbol$1 ? _Symbol$1.toStringTag : undefined;
401
-
402
- /**
403
- * The base implementation of `getTag` without fallbacks for buggy environments.
404
- *
405
- * @private
406
- * @param {*} value The value to query.
407
- * @returns {string} Returns the `toStringTag`.
408
- */
409
- function baseGetTag(value) {
410
- if (value == null) {
411
- return value === undefined ? undefinedTag : nullTag;
412
- }
413
- return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
414
- }
415
-
416
- function _typeof$3(o) { "@babel/helpers - typeof"; return _typeof$3 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof$3(o); }
417
- /**
418
- * Checks if `value` is object-like. A value is object-like if it's not `null`
419
- * and has a `typeof` result of "object".
420
- *
421
- * @static
422
- * @memberOf _
423
- * @since 4.0.0
424
- * @category Lang
425
- * @param {*} value The value to check.
426
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
427
- * @example
428
- *
429
- * _.isObjectLike({});
430
- * // => true
431
- *
432
- * _.isObjectLike([1, 2, 3]);
433
- * // => true
434
- *
435
- * _.isObjectLike(_.noop);
436
- * // => false
437
- *
438
- * _.isObjectLike(null);
439
- * // => false
440
- */
441
- function isObjectLike(value) {
442
- return value != null && _typeof$3(value) == 'object';
443
- }
444
-
445
- function _typeof$2(o) { "@babel/helpers - typeof"; return _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof$2(o); }
446
-
447
- /** `Object#toString` result references. */
448
- var symbolTag = '[object Symbol]';
449
-
450
- /**
451
- * Checks if `value` is classified as a `Symbol` primitive or object.
452
- *
453
- * @static
454
- * @memberOf _
455
- * @since 4.0.0
456
- * @category Lang
457
- * @param {*} value The value to check.
458
- * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
459
- * @example
460
- *
461
- * _.isSymbol(Symbol.iterator);
462
- * // => true
463
- *
464
- * _.isSymbol('abc');
465
- * // => false
466
- */
467
- function isSymbol(value) {
468
- return _typeof$2(value) == 'symbol' || isObjectLike(value) && baseGetTag(value) == symbolTag;
469
- }
470
-
471
- /** Used as references for various `Number` constants. */
472
- var NAN = 0 / 0;
473
-
474
- /** Used to detect bad signed hexadecimal string values. */
475
- var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
476
-
477
- /** Used to detect binary string values. */
478
- var reIsBinary = /^0b[01]+$/i;
479
-
480
- /** Used to detect octal string values. */
481
- var reIsOctal = /^0o[0-7]+$/i;
482
-
483
- /** Built-in method references without a dependency on `root`. */
484
- var freeParseInt = parseInt;
485
-
486
- /**
487
- * Converts `value` to a number.
488
- *
489
- * @static
490
- * @memberOf _
491
- * @since 4.0.0
492
- * @category Lang
493
- * @param {*} value The value to process.
494
- * @returns {number} Returns the number.
495
- * @example
496
- *
497
- * _.toNumber(3.2);
498
- * // => 3.2
499
- *
500
- * _.toNumber(Number.MIN_VALUE);
501
- * // => 5e-324
502
- *
503
- * _.toNumber(Infinity);
504
- * // => Infinity
505
- *
506
- * _.toNumber('3.2');
507
- * // => 3.2
508
- */
509
- function toNumber(value) {
510
- if (typeof value == 'number') {
511
- return value;
512
- }
513
- if (isSymbol(value)) {
514
- return NAN;
515
- }
516
- if (isObject(value)) {
517
- var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
518
- value = isObject(other) ? other + '' : other;
519
- }
520
- if (typeof value != 'string') {
521
- return value === 0 ? value : +value;
522
- }
523
- value = baseTrim(value);
524
- var isBinary = reIsBinary.test(value);
525
- return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
526
- }
527
-
528
- /** Error message constants. */
529
- var FUNC_ERROR_TEXT = 'Expected a function';
530
-
531
- /* Built-in method references for those with the same name as other `lodash` methods. */
532
- var nativeMax = Math.max,
533
- nativeMin = Math.min;
534
-
535
- /**
536
- * Creates a debounced function that delays invoking `func` until after `wait`
537
- * milliseconds have elapsed since the last time the debounced function was
538
- * invoked. The debounced function comes with a `cancel` method to cancel
539
- * delayed `func` invocations and a `flush` method to immediately invoke them.
540
- * Provide `options` to indicate whether `func` should be invoked on the
541
- * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
542
- * with the last arguments provided to the debounced function. Subsequent
543
- * calls to the debounced function return the result of the last `func`
544
- * invocation.
545
- *
546
- * **Note:** If `leading` and `trailing` options are `true`, `func` is
547
- * invoked on the trailing edge of the timeout only if the debounced function
548
- * is invoked more than once during the `wait` timeout.
549
- *
550
- * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
551
- * until to the next tick, similar to `setTimeout` with a timeout of `0`.
552
- *
553
- * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
554
- * for details over the differences between `_.debounce` and `_.throttle`.
555
- *
556
- * @static
557
- * @memberOf _
558
- * @since 0.1.0
559
- * @category Function
560
- * @param {Function} func The function to debounce.
561
- * @param {number} [wait=0] The number of milliseconds to delay.
562
- * @param {Object} [options={}] The options object.
563
- * @param {boolean} [options.leading=false]
564
- * Specify invoking on the leading edge of the timeout.
565
- * @param {number} [options.maxWait]
566
- * The maximum time `func` is allowed to be delayed before it's invoked.
567
- * @param {boolean} [options.trailing=true]
568
- * Specify invoking on the trailing edge of the timeout.
569
- * @returns {Function} Returns the new debounced function.
570
- * @example
571
- *
572
- * // Avoid costly calculations while the window size is in flux.
573
- * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
574
- *
575
- * // Invoke `sendMail` when clicked, debouncing subsequent calls.
576
- * jQuery(element).on('click', _.debounce(sendMail, 300, {
577
- * 'leading': true,
578
- * 'trailing': false
579
- * }));
580
- *
581
- * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
582
- * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
583
- * var source = new EventSource('/stream');
584
- * jQuery(source).on('message', debounced);
585
- *
586
- * // Cancel the trailing debounced invocation.
587
- * jQuery(window).on('popstate', debounced.cancel);
588
- */
589
- function debounce(func, wait, options) {
590
- var lastArgs,
591
- lastThis,
592
- maxWait,
593
- result,
594
- timerId,
595
- lastCallTime,
596
- lastInvokeTime = 0,
597
- leading = false,
598
- maxing = false,
599
- trailing = true;
600
- if (typeof func != 'function') {
601
- throw new TypeError(FUNC_ERROR_TEXT);
602
- }
603
- wait = toNumber(wait) || 0;
604
- if (isObject(options)) {
605
- leading = !!options.leading;
606
- maxing = 'maxWait' in options;
607
- maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
608
- trailing = 'trailing' in options ? !!options.trailing : trailing;
609
- }
610
- function invokeFunc(time) {
611
- var args = lastArgs,
612
- thisArg = lastThis;
613
- lastArgs = lastThis = undefined;
614
- lastInvokeTime = time;
615
- result = func.apply(thisArg, args);
616
- return result;
617
- }
618
- function leadingEdge(time) {
619
- // Reset any `maxWait` timer.
620
- lastInvokeTime = time;
621
- // Start the timer for the trailing edge.
622
- timerId = setTimeout(timerExpired, wait);
623
- // Invoke the leading edge.
624
- return leading ? invokeFunc(time) : result;
625
- }
626
- function remainingWait(time) {
627
- var timeSinceLastCall = time - lastCallTime,
628
- timeSinceLastInvoke = time - lastInvokeTime,
629
- timeWaiting = wait - timeSinceLastCall;
630
- return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
631
- }
632
- function shouldInvoke(time) {
633
- var timeSinceLastCall = time - lastCallTime,
634
- timeSinceLastInvoke = time - lastInvokeTime;
635
-
636
- // Either this is the first call, activity has stopped and we're at the
637
- // trailing edge, the system time has gone backwards and we're treating
638
- // it as the trailing edge, or we've hit the `maxWait` limit.
639
- return lastCallTime === undefined || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
640
- }
641
- function timerExpired() {
642
- var time = now$1();
643
- if (shouldInvoke(time)) {
644
- return trailingEdge(time);
645
- }
646
- // Restart the timer.
647
- timerId = setTimeout(timerExpired, remainingWait(time));
648
- }
649
- function trailingEdge(time) {
650
- timerId = undefined;
651
-
652
- // Only invoke if we have `lastArgs` which means `func` has been
653
- // debounced at least once.
654
- if (trailing && lastArgs) {
655
- return invokeFunc(time);
656
- }
657
- lastArgs = lastThis = undefined;
658
- return result;
659
- }
660
- function cancel() {
661
- if (timerId !== undefined) {
662
- clearTimeout(timerId);
663
- }
664
- lastInvokeTime = 0;
665
- lastArgs = lastCallTime = lastThis = timerId = undefined;
666
- }
667
- function flush() {
668
- return timerId === undefined ? result : trailingEdge(now$1());
669
- }
670
- function debounced() {
671
- var time = now$1(),
672
- isInvoking = shouldInvoke(time);
673
- lastArgs = arguments;
674
- lastThis = this;
675
- lastCallTime = time;
676
- if (isInvoking) {
677
- if (timerId === undefined) {
678
- return leadingEdge(lastCallTime);
679
- }
680
- if (maxing) {
681
- // Handle invocations in a tight loop.
682
- clearTimeout(timerId);
683
- timerId = setTimeout(timerExpired, wait);
684
- return invokeFunc(lastCallTime);
685
- }
686
- }
687
- if (timerId === undefined) {
688
- timerId = setTimeout(timerExpired, wait);
689
- }
690
- return result;
691
- }
692
- debounced.cancel = cancel;
693
- debounced.flush = flush;
694
- return debounced;
695
- }
696
-
697
- var createCompletionCacheManager = function createCompletionCacheManager(getFromLanguageService) {
698
- var completionList;
699
- var lastWord;
700
- return {
701
- getCompletionItems: function getCompletionItems(word, resource, position) {
702
- var shouldGetItems = !lastWord || !word || !(word !== null && word !== void 0 && word.includes(lastWord));
703
- if (shouldGetItems) {
704
- completionList = getFromLanguageService(resource, position);
705
- }
706
- lastWord = word;
707
- return completionList;
708
- }
709
- };
710
- };
711
-
712
- function createCompletionFilteredText(userInput, completionItem) {
713
- if (!userInput) return completionItem.filterText;
714
- var containedInFilterText = completionItem.filterText.toLowerCase().includes(userInput.toLowerCase());
715
- if (!containedInFilterText) return completionItem.filterText;
716
- return "".concat(userInput).concat(completionItem.filterText);
717
- }
718
- function getFocusedItem(completionItems, userInput) {
719
- var firstCompletionItem = completionItems[0];
720
- if (!userInput) return firstCompletionItem;
721
- var firstMatchingItem = completionItems.find(function (item) {
722
- var _item$filterText;
723
- return (_item$filterText = item.filterText) === null || _item$filterText === void 0 ? void 0 : _item$filterText.toLowerCase().startsWith(userInput.toLowerCase());
724
- });
725
- return firstMatchingItem !== null && firstMatchingItem !== void 0 ? firstMatchingItem : firstCompletionItem;
726
- }
727
-
728
- function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$1(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
729
- function _typeof$1(o) { "@babel/helpers - typeof"; return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof$1(o); }
730
- function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray$1(r, e) || _nonIterableRest(); }
731
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
732
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
733
- function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
734
- function _toConsumableArray$1(r) { return _arrayWithoutHoles$1(r) || _iterableToArray$1(r) || _unsupportedIterableToArray$1(r) || _nonIterableSpread$1(); }
735
- function _nonIterableSpread$1() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
736
- function _unsupportedIterableToArray$1(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$1(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$1(r, a) : void 0; } }
737
- function _iterableToArray$1(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
738
- function _arrayWithoutHoles$1(r) { if (Array.isArray(r)) return _arrayLikeToArray$1(r); }
739
- function _arrayLikeToArray$1(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
740
- function _regeneratorRuntime$1() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime$1 = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof$1(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof$1(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
741
- function asyncGeneratorStep$1(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
742
- function _asyncToGenerator$1(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep$1(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep$1(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
743
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
744
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey$1(o.key), o); } }
745
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
746
- function _defineProperty$1(e, r, t) { return (r = _toPropertyKey$1(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
747
- function _toPropertyKey$1(t) { var i = _toPrimitive$1(t, "string"); return "symbol" == _typeof$1(i) ? i : i + ""; }
748
- function _toPrimitive$1(t, r) { if ("object" != _typeof$1(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof$1(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
749
-
750
- // --- diagnostics ---
751
-
752
- var DiagnosticsAdapter = /*#__PURE__*/function () {
753
- function DiagnosticsAdapter(_monacoInstance, _languageId, _worker, defaults, onSchemaChange) {
754
- var _this = this;
755
- _classCallCheck(this, DiagnosticsAdapter);
756
- _defineProperty$1(this, "_disposables", []);
757
- _defineProperty$1(this, "_contentListener", Object.create(null));
758
- _defineProperty$1(this, "_configurationListener", Object.create(null));
759
- _defineProperty$1(this, "_schemaListener", Object.create(null));
760
- _defineProperty$1(this, "_cursorListener", Object.create(null));
761
- _defineProperty$1(this, "_debouncedValidations", Object.create(null));
762
- this._monacoInstance = _monacoInstance;
763
- this._languageId = _languageId;
764
- this._worker = _worker;
765
- this.defaults = defaults;
766
- var onModelAdd = function onModelAdd(model) {
767
- var languageId = model.getLanguageId();
768
- var modelUri = model.uri.toString();
769
- if (languageId !== _this._languageId) {
770
- return;
771
- }
772
- var debouncedValidation = _this.getOrCreateDebouncedValidation(model, languageId);
773
- _this._contentListener[modelUri] = model.onDidChangeContent(function (e) {
774
- var intervalsToValidate = changeEventToIntervals(e);
775
- debouncedValidation(intervalsToValidate);
776
- });
777
- _this._configurationListener[modelUri] = _this.defaults.onDidChange(function () {
778
- self.setTimeout(function () {
779
- return _this._doValidate(model, languageId, []);
780
- }, 0);
781
- });
782
- _this._schemaListener[modelUri] = onSchemaChange(function () {
783
- self.setTimeout(function () {
784
- return _this._doValidate(model, languageId, []);
785
- }, 0);
786
- });
787
- };
788
- var onEditorAdd = function onEditorAdd(editor) {
789
- var editorId = editor.getId();
790
- if (!_this._cursorListener[editorId]) {
791
- editor.onDidDispose(function () {
792
- var _this$_cursorListener;
793
- (_this$_cursorListener = _this._cursorListener[editorId]) === null || _this$_cursorListener === void 0 || _this$_cursorListener.dispose();
794
- delete _this._cursorListener[editorId];
795
- });
796
- _this._cursorListener[editorId] = editor.onDidChangeCursorSelection(function (e) {
797
- var model = editor.getModel();
798
- var languageId = model.getLanguageId();
799
- if (languageId !== _this._languageId) {
800
- return;
801
- }
802
- var cursorOffset = model.getOffsetAt(e.selection.getPosition());
803
- var debouncedValidation = _this.getOrCreateDebouncedValidation(model, languageId);
804
- debouncedValidation([{
805
- start: cursorOffset,
806
- end: cursorOffset
807
- }]);
808
- });
809
- }
810
- };
811
- var onModelRemoved = function onModelRemoved(model) {
812
- _this._monacoInstance.editor.setModelMarkers(model, _this._languageId, []);
813
- var uriStr = model.uri.toString();
814
- var contentListener = _this._contentListener[uriStr];
815
- if (contentListener) {
816
- contentListener.dispose();
817
- delete _this._contentListener[uriStr];
818
- }
819
- var configurationListener = _this._configurationListener[uriStr];
820
- if (configurationListener) {
821
- configurationListener.dispose();
822
- delete _this._configurationListener[uriStr];
823
- }
824
- var schemaListener = _this._schemaListener[uriStr];
825
- if (schemaListener) {
826
- schemaListener.dispose();
827
- delete _this._schemaListener[uriStr];
828
- }
829
- var debouncedValidation = _this._debouncedValidations[uriStr];
830
- if (debouncedValidation) {
831
- debouncedValidation.cancel();
832
- delete _this._debouncedValidations[uriStr];
833
- }
834
- };
835
- if (this.defaults.languageSettings.enableQuickFixes) {
836
- this._disposables.push(monaco__namespace.languages.registerCodeActionProvider(this._languageId, {
837
- provideCodeActions: function () {
838
- var _provideCodeActions = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee(model, range, context, _token) {
839
- var startOffset, endOffset, showQuickFix, actions;
840
- return _regeneratorRuntime$1().wrap(function _callee$(_context) {
841
- while (1) switch (_context.prev = _context.next) {
842
- case 0:
843
- startOffset = model.getOffsetAt(range.getStartPosition());
844
- endOffset = model.getOffsetAt(range.getEndPosition()); // We want to show the quick fix option only if we have markers in our selected range
845
- showQuickFix = context.markers.length > 0;
846
- _context.next = 5;
847
- return _this.getMonacoCodeActions(model, startOffset, endOffset, showQuickFix);
848
- case 5:
849
- actions = _context.sent;
850
- return _context.abrupt("return", {
851
- actions: actions,
852
- dispose: function dispose() {}
853
- });
854
- case 7:
855
- case "end":
856
- return _context.stop();
857
- }
858
- }, _callee);
859
- }));
860
- function provideCodeActions(_x, _x2, _x3, _x4) {
861
- return _provideCodeActions.apply(this, arguments);
862
- }
863
- return provideCodeActions;
864
- }()
865
- }));
866
- }
867
- this._disposables.push(this._monacoInstance.editor.onDidCreateEditor(onEditorAdd));
868
- this._disposables.push(this._monacoInstance.editor.onDidCreateModel(onModelAdd));
869
- this._disposables.push(this._monacoInstance.editor.onWillDisposeModel(onModelRemoved));
870
- this._disposables.push(this._monacoInstance.editor.onDidChangeModelLanguage(function (event) {
871
- onModelRemoved(event.model);
872
- onModelAdd(event.model);
873
- }));
874
- this._disposables.push({
875
- dispose: function dispose() {
876
- for (var key in _this._contentListener) {
877
- _this._contentListener[key].dispose();
878
- }
879
- for (var _key in _this._cursorListener) {
880
- _this._cursorListener[_key].dispose();
881
- }
882
- for (var _key2 in _this._debouncedValidations) {
883
- _this._debouncedValidations[_key2].cancel();
884
- }
885
- }
886
- });
887
- this._monacoInstance.editor.getModels().forEach(onModelAdd);
888
- this._monacoInstance.editor.getEditors().forEach(onEditorAdd);
889
- }
890
- return _createClass(DiagnosticsAdapter, [{
891
- key: "getMonacoCodeActions",
892
- value: function () {
893
- var _getMonacoCodeActions = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee2(model, startOffset, endOffset, enableQuickFix) {
894
- var _this2 = this;
895
- var actions, worker, resource, codeActions, _loop, _ret, i;
896
- return _regeneratorRuntime$1().wrap(function _callee2$(_context3) {
897
- while (1) switch (_context3.prev = _context3.next) {
898
- case 0:
899
- actions = [];
900
- _context3.next = 3;
901
- return this._worker(model.uri);
902
- case 3:
903
- worker = _context3.sent;
904
- resource = model.uri;
905
- _context3.next = 7;
906
- return worker.getResultActions(resource.toString(), startOffset, endOffset);
907
- case 7:
908
- codeActions = _context3.sent;
909
- _loop = /*#__PURE__*/_regeneratorRuntime$1().mark(function _loop() {
910
- var _this2$defaults$langu;
911
- var codeAction, codeActionKind, changes, edits;
912
- return _regeneratorRuntime$1().wrap(function _loop$(_context2) {
913
- while (1) switch (_context2.prev = _context2.next) {
914
- case 0:
915
- codeAction = codeActions[i];
916
- if (!codeAction.kind.includes('Extract Function')) {
917
- _context2.next = 3;
918
- break;
919
- }
920
- return _context2.abrupt("return", 0);
921
- case 3:
922
- codeActionKind = (_this2$defaults$langu = _this2.defaults.languageSettings.quickFixCodeActions) !== null && _this2$defaults$langu !== void 0 && _this2$defaults$langu.find(function (actionKind) {
923
- return codeAction.kind.includes(actionKind);
924
- }) ? 'quickfix' : 'custom';
925
- if (!(codeActionKind === 'quickfix' && !enableQuickFix)) {
926
- _context2.next = 6;
927
- break;
928
- }
929
- return _context2.abrupt("return", {
930
- v: void 0
931
- });
932
- case 6:
933
- changes = codeAction.changes;
934
- edits = changes.map(function (change) {
935
- var _change$insertText;
936
- var startPosition = model.getPositionAt(change.start);
937
- var endPosition = model.getPositionAt(change.start + change.deleteLength);
938
- return {
939
- resource: model.uri,
940
- textEdit: {
941
- range: {
942
- startLineNumber: startPosition.lineNumber,
943
- startColumn: startPosition.column,
944
- endLineNumber: endPosition.lineNumber,
945
- endColumn: endPosition.column
946
- },
947
- text: (_change$insertText = change.insertText) !== null && _change$insertText !== void 0 ? _change$insertText : ''
948
- }
949
- };
950
- });
951
- actions.push({
952
- title: codeAction.title,
953
- diagnostics: [],
954
- kind: codeActionKind,
955
- edit: {
956
- edits: _toConsumableArray$1(edits)
957
- }
958
- });
959
- case 9:
960
- case "end":
961
- return _context2.stop();
962
- }
963
- }, _loop);
964
- });
965
- i = 0;
966
- case 10:
967
- if (!(i < codeActions.length)) {
968
- _context3.next = 20;
969
- break;
970
- }
971
- return _context3.delegateYield(_loop(), "t0", 12);
972
- case 12:
973
- _ret = _context3.t0;
974
- if (!(_ret === 0)) {
975
- _context3.next = 15;
976
- break;
977
- }
978
- return _context3.abrupt("continue", 17);
979
- case 15:
980
- if (!_ret) {
981
- _context3.next = 17;
982
- break;
983
- }
984
- return _context3.abrupt("return", _ret.v);
985
- case 17:
986
- i++;
987
- _context3.next = 10;
988
- break;
989
- case 20:
990
- return _context3.abrupt("return", actions);
991
- case 21:
992
- case "end":
993
- return _context3.stop();
994
- }
995
- }, _callee2, this);
996
- }));
997
- function getMonacoCodeActions(_x5, _x6, _x7, _x8) {
998
- return _getMonacoCodeActions.apply(this, arguments);
999
- }
1000
- return getMonacoCodeActions;
1001
- }()
1002
- }, {
1003
- key: "getOrCreateDebouncedValidation",
1004
- value: function getOrCreateDebouncedValidation(model, languageId) {
1005
- var _this3 = this;
1006
- var modelUri = model.uri.toString();
1007
- if (!this._debouncedValidations[modelUri]) {
1008
- this._debouncedValidations[modelUri] = debounce(function (intervals) {
1009
- return _this3._doValidate(model, languageId, intervals);
1010
- }, 500);
1011
- }
1012
- return this._debouncedValidations[modelUri];
1013
- }
1014
- }, {
1015
- key: "dispose",
1016
- value: function dispose() {
1017
- this._disposables.forEach(function (d) {
1018
- return d && d.dispose();
1019
- });
1020
- this._disposables = [];
1021
- }
1022
- }, {
1023
- key: "_doValidate",
1024
- value: function _doValidate(model, languageId, intervals) {
1025
- var _this4 = this;
1026
- if (model.isDisposed()) {
1027
- return;
1028
- }
1029
- var resource = model.uri;
1030
- var versionNumberBefore = model.getVersionId();
1031
- this._worker(resource).then(function (worker) {
1032
- return worker.doValidation(resource.toString(), intervals);
1033
- }).then(function (diagnostics) {
1034
- var newModel = _this4._monacoInstance.editor.getModel(resource);
1035
- var versionId = newModel.getVersionId();
1036
- if (versionId !== versionNumberBefore) {
1037
- return;
1038
- }
1039
- var markers = diagnostics.map(function (d) {
1040
- return toDiagnostics(resource, d);
1041
- });
1042
- var model = _this4._monacoInstance.editor.getModel(resource);
1043
- var oldDecorations = model.getAllDecorations().filter(function (decoration) {
1044
- return decoration.options.className == 'squiggly-error';
1045
- }).map(function (decoration) {
1046
- return decoration.id;
1047
- });
1048
- if (model && model.getLanguageId() === languageId) {
1049
- var syntaxErrorAsMarkDown = _this4.defaults.languageSettings.syntaxErrorAsMarkDown;
1050
- if (!syntaxErrorAsMarkDown || !syntaxErrorAsMarkDown.enableSyntaxErrorAsMarkDown) {
1051
- // Remove previous syntax error decorations and set the new markers (for example, when disabling syntaxErrorAsMarkDown after it was enabled)
1052
- model.deltaDecorations(oldDecorations, []);
1053
- _this4._monacoInstance.editor.setModelMarkers(model, languageId, markers);
1054
- } else {
1055
- // Add custom popup for syntax error: icon, header and message as markdown
1056
- var header = syntaxErrorAsMarkDown.header ? "**".concat(syntaxErrorAsMarkDown.header, "** \n\n") : '';
1057
- var icon = syntaxErrorAsMarkDown.icon ? "![](".concat(syntaxErrorAsMarkDown.icon, ")") : '';
1058
- var popupErrorHoverHeaderMessage = "".concat(icon, " ").concat(header);
1059
- var newDecorations = markers.map(function (marker) {
1060
- return {
1061
- range: {
1062
- startLineNumber: marker.startLineNumber,
1063
- startColumn: marker.startColumn,
1064
- endLineNumber: marker.endLineNumber,
1065
- endColumn: marker.endColumn
1066
- },
1067
- options: {
1068
- hoverMessage: {
1069
- value: popupErrorHoverHeaderMessage + marker.message
1070
- },
1071
- className: 'squiggly-error',
1072
- // monaco syntax error style (red underline)
1073
- zIndex: 100,
1074
- // This message will be the upper most mesage in the popup
1075
- overviewRuler: {
1076
- // The color indication on the right ruler
1077
- color: 'rgb(255, 18, 18, 0.7)',
1078
- position: monaco__namespace.editor.OverviewRulerLane.Right
1079
- },
1080
- minimap: {
1081
- color: 'rgb(255, 18, 18, 0.7)',
1082
- position: monaco__namespace.editor.MinimapPosition.Inline
1083
- }
1084
- }
1085
- };
1086
- });
1087
- var oldMarkers = monaco__namespace.editor.getModelMarkers({
1088
- owner: languageId,
1089
- resource: resource
1090
- });
1091
- if (oldMarkers && oldMarkers.length > 0) {
1092
- // In case there were previous markers, remove their decorations (for example, when enabling syntaxErrorAsMarkDown after it was disabled)
1093
- oldDecorations = [];
1094
- // Remove previous markers
1095
- _this4._monacoInstance.editor.setModelMarkers(model, languageId, []);
1096
- }
1097
-
1098
- // Remove previous syntax error decorations and set the new decorations
1099
- model.deltaDecorations(oldDecorations, newDecorations);
1100
- }
1101
- }
1102
- }).then(undefined, function (err) {
1103
- console.error(err);
1104
- });
1105
- }
1106
- }]);
1107
- }();
1108
- function changeEventToIntervals(e) {
1109
- return e.changes.map(function (change) {
1110
- return {
1111
- start: change.rangeOffset,
1112
- end: change.rangeOffset + change.text.length
1113
- };
1114
- });
1115
- }
1116
- function toSeverity(lsSeverity) {
1117
- switch (lsSeverity) {
1118
- case main.DiagnosticSeverity.Error:
1119
- return monaco__namespace.MarkerSeverity.Error;
1120
- case main.DiagnosticSeverity.Warning:
1121
- return monaco__namespace.MarkerSeverity.Warning;
1122
- case main.DiagnosticSeverity.Information:
1123
- return monaco__namespace.MarkerSeverity.Info;
1124
- case main.DiagnosticSeverity.Hint:
1125
- return monaco__namespace.MarkerSeverity.Hint;
1126
- default:
1127
- return monaco__namespace.MarkerSeverity.Info;
1128
- }
1129
- }
1130
- function toDiagnostics(resource, diag) {
1131
- var code = typeof diag.code === 'number' ? String(diag.code) : diag.code;
1132
- return {
1133
- severity: toSeverity(diag.severity),
1134
- startLineNumber: diag.range.start.line + 1,
1135
- startColumn: diag.range.start.character + 1,
1136
- endLineNumber: diag.range.end.line + 1,
1137
- endColumn: diag.range.end.character + 1,
1138
- message: diag.message,
1139
- code: code,
1140
- source: diag.source
1141
- };
1142
- }
1143
- /**
1144
- * Copy of Kusto.Language.Editor.ClassificationKind we don't have to depend on it in this file
1145
- */
1146
- var ClassificationKind = {
1147
- PlainText: 0,
1148
- Comment: 1,
1149
- Punctuation: 2,
1150
- Directive: 3,
1151
- Literal: 4,
1152
- StringLiteral: 5,
1153
- Type: 6,
1154
- Column: 7,
1155
- Table: 8,
1156
- Database: 9,
1157
- Function: 10,
1158
- Parameter: 11,
1159
- Variable: 12,
1160
- Identifier: 13,
1161
- ClientParameter: 14,
1162
- QueryParameter: 15,
1163
- ScalarOperator: 16,
1164
- MathOperator: 17,
1165
- QueryOperator: 18,
1166
- Command: 19,
1167
- Keyword: 20,
1168
- MaterializedView: 21,
1169
- SchemaMember: 22,
1170
- SignatureParameter: 23,
1171
- Option: 24
1172
- };
1173
- var ClassificationKindNames = {};
1174
- for (var _i = 0, _Object$entries = Object.entries(ClassificationKind); _i < _Object$entries.length; _i++) {
1175
- var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
1176
- key = _Object$entries$_i[0],
1177
- value = _Object$entries$_i[1];
1178
- ClassificationKindNames[value] = key;
1179
- }
1180
-
1181
- // commented here is the color definitions are were defined by v1 intellisense terminology:
1182
- // { token: 'comment', foreground: '008000' }, // CommentToken Green
1183
- // { token: 'variable.predefined', foreground: '800080' }, // CalculatedColumnToken Purple
1184
- // { token: 'function', foreground: '0000FF' }, // FunctionNameToken Blue
1185
- // { token: 'operator.sql', foreground: 'FF4500' }, // OperatorToken OrangeRed (now changed to darker color CC3700 because wasn't accessible)
1186
- // { token: 'string', foreground: 'B22222' }, // StringLiteralToken Firebrick
1187
- // { token: 'operator.scss', foreground: '0000FF' }, // SubOperatorToken Blue
1188
- // { token: 'variable', foreground: 'C71585' }, // TableColumnToken MediumVioletRed
1189
- // { token: 'variable.parameter', foreground: '9932CC' }, // TableToken DarkOrchid
1190
- // { token: '', foreground: '000000' }, // UnknownToken, PlainTextToken Black
1191
- // { token: 'type', foreground: '0000FF' }, // DataTypeToken Blue
1192
- // { token: 'tag', foreground: '0000FF' }, // ControlCommandToken Blue
1193
- // { token: 'annotation', foreground: '2B91AF' }, // QueryParametersToken FF2B91AF
1194
- // { token: 'keyword', foreground: '0000FF' }, // CslCommandToken, PluginToken Blue
1195
- // { token: 'number', foreground: '191970' }, // LetVariablesToken MidnightBlue
1196
- // { token: 'annotation', foreground: '9400D3' }, // ClientDirectiveToken DarkViolet
1197
- // { token: 'invalid', background: 'cd3131' },
1198
- var classificationToColorLight = {
1199
- Column: 'C71585',
1200
- Comment: '008000',
1201
- Database: 'C71585',
1202
- Function: '0000FF',
1203
- Identifier: '000000',
1204
- Keyword: '0000FF',
1205
- Literal: 'B22222',
1206
- ScalarOperator: '0000FF',
1207
- MaterializedView: 'C71585',
1208
- MathOperator: '000000',
1209
- Command: '0000FF',
1210
- Parameter: '2B91AF',
1211
- PlainText: '000000',
1212
- Punctuation: '000000',
1213
- QueryOperator: 'CC3700',
1214
- QueryParameter: 'CC3700',
1215
- StringLiteral: 'B22222',
1216
- Table: 'C71585',
1217
- Type: '0000FF',
1218
- Variable: '191970',
1219
- Directive: '9400D3',
1220
- ClientParameter: 'b5cea8',
1221
- SchemaMember: 'C71585',
1222
- SignatureParameter: '2B91AF',
1223
- Option: '000000'
1224
- };
1225
- var classificationToColorDark = {
1226
- Column: '4ec9b0',
1227
- Comment: '6A9B34',
1228
- Database: 'c586c0',
1229
- Function: 'dcdcaa',
1230
- Identifier: 'd4d4d4',
1231
- Keyword: '569cd6',
1232
- Literal: 'ce9178',
1233
- ScalarOperator: '569cd6',
1234
- MaterializedView: 'c586c0',
1235
- MathOperator: 'd4d4d4',
1236
- Command: 'd4d4d4',
1237
- Parameter: '2B91AF',
1238
- PlainText: 'd4d4d4',
1239
- Punctuation: 'd4d4d4',
1240
- QueryOperator: '9cdcfe',
1241
- QueryParameter: '9cdcfe',
1242
- StringLiteral: 'ce9178',
1243
- Table: 'c586c0',
1244
- Type: '569cd6',
1245
- Variable: 'd7ba7d',
1246
- Directive: 'b5cea8',
1247
- ClientParameter: 'b5cea8',
1248
- SchemaMember: '4ec9b0',
1249
- SignatureParameter: '2B91AF',
1250
- Option: 'd4d4d4'
1251
- };
1252
- var ColorizationAdapter = /*#__PURE__*/function () {
1253
- function ColorizationAdapter(_monacoInstance, _languageId, _worker, defaults, onSchemaChange) {
1254
- var _this5 = this;
1255
- _classCallCheck(this, ColorizationAdapter);
1256
- _defineProperty$1(this, "_disposables", []);
1257
- _defineProperty$1(this, "_contentListener", Object.create(null));
1258
- _defineProperty$1(this, "_configurationListener", Object.create(null));
1259
- _defineProperty$1(this, "_schemaListener", Object.create(null));
1260
- _defineProperty$1(this, "decorations", []);
1261
- this._monacoInstance = _monacoInstance;
1262
- this._languageId = _languageId;
1263
- this._worker = _worker;
1264
- injectCss();
1265
- var onModelAdd = function onModelAdd(model) {
1266
- var languageId = model.getLanguageId();
1267
- if (languageId !== _this5._languageId) {
1268
- return;
1269
- }
1270
- var debouncedColorization = debounce(function (intervals) {
1271
- return _this5._doColorization(model, languageId, intervals);
1272
- }, 500);
1273
- _this5._contentListener[model.uri.toString()] = model.onDidChangeContent(function (e) {
1274
- // Changes are represented as a range in doc before change, plus the text that it was replaced with.
1275
- // We are interested in the range _after_ the change (since that's what we need to colorize).
1276
- // following logic calculates that.
1277
- var intervalsToColorize = changeEventToIntervals(e);
1278
- debouncedColorization(intervalsToColorize);
1279
- });
1280
- _this5._configurationListener[model.uri.toString()] = defaults.onDidChange(function () {
1281
- self.setTimeout(function () {
1282
- return _this5._doColorization(model, languageId, []);
1283
- }, 0);
1284
- });
1285
- _this5._schemaListener[model.uri.toString()] = onSchemaChange(function () {
1286
- self.setTimeout(function () {
1287
- return _this5._doColorization(model, languageId, []);
1288
- }, 0);
1289
- });
1290
- };
1291
- var onModelRemoved = function onModelRemoved(model) {
1292
- model.deltaDecorations(_this5.decorations, []);
1293
- var uriStr = model.uri.toString();
1294
- var contentListener = _this5._contentListener[uriStr];
1295
- if (contentListener) {
1296
- contentListener.dispose();
1297
- delete _this5._contentListener[uriStr];
1298
- }
1299
- var configurationListener = _this5._configurationListener[uriStr];
1300
- if (configurationListener) {
1301
- configurationListener.dispose();
1302
- delete _this5._configurationListener[uriStr];
1303
- }
1304
- var schemaListener = _this5._configurationListener[uriStr];
1305
- if (schemaListener) {
1306
- schemaListener.dispose();
1307
- delete _this5._schemaListener[uriStr];
1308
- }
1309
- };
1310
- this._disposables.push(this._monacoInstance.editor.onDidCreateModel(onModelAdd));
1311
- this._disposables.push(this._monacoInstance.editor.onWillDisposeModel(onModelRemoved));
1312
- this._disposables.push(this._monacoInstance.editor.onDidChangeModelLanguage(function (event) {
1313
- onModelRemoved(event.model);
1314
- onModelAdd(event.model);
1315
- }));
1316
- this._disposables.push({
1317
- dispose: function dispose() {
1318
- for (var _key3 in _this5._contentListener) {
1319
- _this5._contentListener[_key3].dispose();
1320
- }
1321
- }
1322
- });
1323
- this._monacoInstance.editor.getModels().forEach(onModelAdd);
1324
- }
1325
- return _createClass(ColorizationAdapter, [{
1326
- key: "dispose",
1327
- value: function dispose() {
1328
- this._disposables.forEach(function (d) {
1329
- return d && d.dispose();
1330
- });
1331
- this._disposables = [];
1332
- }
1333
- }, {
1334
- key: "_doColorization",
1335
- value: function _doColorization(model, languageId, intervals) {
1336
- var _this6 = this;
1337
- if (model.isDisposed()) {
1338
- return;
1339
- }
1340
- var resource = model.uri;
1341
- var versionNumberBeforeColorization = model.getVersionId();
1342
- this._worker(resource).then(function (worker) {
1343
- if (model.isDisposed()) {
1344
- return;
1345
- }
1346
- return worker.doColorization(resource.toString(), intervals);
1347
- }).then(function (colorizationRanges) {
1348
- if (model.isDisposed()) {
1349
- return;
1350
- }
1351
- var newModel = _this6._monacoInstance.editor.getModel(model.uri);
1352
- var versionId = newModel.getVersionId();
1353
-
1354
- // don't colorize an older version of the document.
1355
- if (versionId !== versionNumberBeforeColorization) {
1356
- return;
1357
- }
1358
- var decorationRanges = colorizationRanges.map(function (colorizationRange) {
1359
- var decorations = colorizationRange.classifications.map(function (classification) {
1360
- return toDecoration(model, classification);
1361
- })
1362
- // The following line will prevent things that aren't going to be colorized anyway to get a CSS class.
1363
- // This will prevent the case where the non-semantic colorizer already figured out that a keyword needs
1364
- // to be colorized, but the outdated semantic colorizer still thinks it's a plain text and wants it colored
1365
- // in black.
1366
- .filter(function (d) {
1367
- return d.options.inlineClassName !== 'PlainText' && d.options.inlineClassName != 'Identifier';
1368
- });
1369
- var firstImpactedLine = model.getPositionAt(colorizationRange.absoluteStart).lineNumber;
1370
- var endPosition = model.getPositionAt(colorizationRange.absoluteEnd);
1371
-
1372
- // A token that ends in the first column of the next line is not considered to be part of that line.
1373
- var lastImpactedLine = endPosition.column == 1 && endPosition.lineNumber > 1 ? endPosition.lineNumber - 1 : endPosition.lineNumber;
1374
- return {
1375
- decorations: decorations,
1376
- firstImpactedLine: firstImpactedLine,
1377
- lastImpactedLine: lastImpactedLine
1378
- };
1379
- });
1380
-
1381
- // Compute the previous decorations we want to replace with the new ones.
1382
- var oldDecorations = decorationRanges.map(function (range) {
1383
- return model.getLinesDecorations(range.firstImpactedLine, range.lastImpactedLine).filter(function (d) {
1384
- return classificationToColorLight[d.options.inlineClassName];
1385
- }) // Don't delete any other decorations
1386
- .map(function (d) {
1387
- return d.id;
1388
- });
1389
- }).reduce(function (prev, curr) {
1390
- return prev.concat(curr);
1391
- }, []);
1392
-
1393
- // Flatten decoration groups to an array of decorations
1394
- var newDecorations = decorationRanges.reduce(function (prev, next) {
1395
- return prev.concat(next.decorations);
1396
- }, []);
1397
- if (model && model.getLanguageId() === languageId) {
1398
- _this6.decorations = model.deltaDecorations(oldDecorations, newDecorations);
1399
- }
1400
- }).catch(function (err) {
1401
- // Hack to avoid crashing calling code, while still logging the
1402
- // error. Might be better to just let the error propagate
1403
- // normally, but that would require more investigation.
1404
- setTimeout(function () {
1405
- throw err;
1406
- }, 0);
1407
- });
1408
- }
1409
- }]);
1410
- }();
1411
-
1412
- /**
1413
- * Generates a mapping between ClassificationKind and color.
1414
- */
1415
- function getClassificationColorTriplets() {
1416
- var result = Object.keys(ClassificationKind).map(function (key) {
1417
- return {
1418
- classification: key,
1419
- colorLight: classificationToColorLight[key],
1420
- colorDark: classificationToColorDark[key]
1421
- };
1422
- });
1423
- return result;
1424
- }
1425
-
1426
- /**
1427
- * Returns a string which is a css describing all tokens and their colors.
1428
- * looks a little bit something like this:
1429
- *
1430
- * .vs .Literal {color: '#000000';} .vs-dark .Literal {color: '#FFFFFF';}
1431
- * .vs .Comment {color: '#111111';} .vs-dark .Comment {color: '#EEEEEE';}
1432
- */
1433
- function getCssForClassification() {
1434
- var classificationColorTriplets = getClassificationColorTriplets();
1435
- var cssInnerHtml = classificationColorTriplets.map(function (pair) {
1436
- return ".vs .".concat(pair.classification, " {color: #").concat(pair.colorLight, ";} .vs-dark .").concat(pair.classification, " {color: #").concat(pair.colorDark, ";}");
1437
- }).join('\n');
1438
- return cssInnerHtml;
1439
- }
1440
-
1441
- /**
1442
- * Inject a CSS sheet to the head of document, coloring kusto elements by classification.
1443
- * TODO: make idempotent
1444
- */
1445
- function injectCss() {
1446
- var container = document.getElementsByTagName('head')[0];
1447
- var style = document.createElement('style');
1448
- style.type = 'text/css';
1449
- style.media = 'screen';
1450
- container.appendChild(style);
1451
- style.innerHTML = getCssForClassification();
1452
- }
1453
- function toDecoration(model, classification) {
1454
- var start = model.getPositionAt(classification.start);
1455
- var end = model.getPositionAt(classification.start + classification.length);
1456
- var range = new monaco__namespace.Range(start.lineNumber, start.column, end.lineNumber, end.column);
1457
- var inlineClassName = ClassificationKindNames[classification.kind];
1458
- return {
1459
- range: range,
1460
- options: {
1461
- inlineClassName: inlineClassName,
1462
- stickiness: monaco__namespace.editor.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges
1463
- }
1464
- };
1465
- }
1466
- // --- completion ------
1467
-
1468
- function fromPosition(position) {
1469
- if (!position) {
1470
- return void 0;
1471
- }
1472
- return {
1473
- character: position.column - 1,
1474
- line: position.lineNumber - 1
1475
- };
1476
- }
1477
- function fromRange(range) {
1478
- if (!range) {
1479
- return void 0;
1480
- }
1481
- return {
1482
- start: fromPosition(range.getStartPosition()),
1483
- end: fromPosition(range.getEndPosition())
1484
- };
1485
- }
1486
- function toRange(range) {
1487
- if (!range) {
1488
- return void 0;
1489
- }
1490
- return new monaco__namespace.Range(range.start.line + 1, range.start.character + 1, range.end.line + 1, range.end.character + 1);
1491
- }
1492
- function toCompletionItemKind(kind) {
1493
- var mItemKind = monaco__namespace.languages.CompletionItemKind;
1494
- switch (kind) {
1495
- case main.CompletionItemKind.Text:
1496
- return mItemKind.Text;
1497
- case main.CompletionItemKind.Method:
1498
- return mItemKind.Method;
1499
- case main.CompletionItemKind.Function:
1500
- return mItemKind.Function;
1501
- case main.CompletionItemKind.Constructor:
1502
- return mItemKind.Constructor;
1503
- case main.CompletionItemKind.Field:
1504
- return mItemKind.Field;
1505
- case main.CompletionItemKind.Variable:
1506
- return mItemKind.Variable;
1507
- case main.CompletionItemKind.Class:
1508
- return mItemKind.Class;
1509
- case main.CompletionItemKind.Interface:
1510
- return mItemKind.Interface;
1511
- case main.CompletionItemKind.Module:
1512
- return mItemKind.Module;
1513
- case main.CompletionItemKind.Property:
1514
- return mItemKind.Property;
1515
- case main.CompletionItemKind.Unit:
1516
- return mItemKind.Unit;
1517
- case main.CompletionItemKind.Value:
1518
- return mItemKind.Value;
1519
- case main.CompletionItemKind.Enum:
1520
- return mItemKind.Enum;
1521
- case main.CompletionItemKind.Keyword:
1522
- return mItemKind.Keyword;
1523
- case main.CompletionItemKind.Snippet:
1524
- return mItemKind.Snippet;
1525
- case main.CompletionItemKind.Color:
1526
- return mItemKind.Color;
1527
- case main.CompletionItemKind.File:
1528
- return mItemKind.File;
1529
- case main.CompletionItemKind.Reference:
1530
- return mItemKind.Reference;
1531
- }
1532
- return mItemKind.Property;
1533
- }
1534
- function toTextEdit(textEdit) {
1535
- if (!textEdit) {
1536
- return void 0;
1537
- }
1538
- return {
1539
- range: toRange(textEdit.range),
1540
- text: textEdit.newText
1541
- };
1542
- }
1543
- var DEFAULT_DOCS_BASE_URL = 'https://learn.microsoft.com/azure/data-explorer/kusto/query';
1544
- var CompletionAdapter = /*#__PURE__*/function () {
1545
- function CompletionAdapter(workerAccessor, languageSettings) {
1546
- _classCallCheck(this, CompletionAdapter);
1547
- this.languageSettings = languageSettings;
1548
- var getFromLanguageService = /*#__PURE__*/function () {
1549
- var _ref = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee3(resource, position) {
1550
- var worker;
1551
- return _regeneratorRuntime$1().wrap(function _callee3$(_context4) {
1552
- while (1) switch (_context4.prev = _context4.next) {
1553
- case 0:
1554
- _context4.next = 2;
1555
- return workerAccessor(resource);
1556
- case 2:
1557
- worker = _context4.sent;
1558
- return _context4.abrupt("return", worker.doComplete(resource.toString(), position));
1559
- case 4:
1560
- case "end":
1561
- return _context4.stop();
1562
- }
1563
- }, _callee3);
1564
- }));
1565
- return function getFromLanguageService(_x9, _x10) {
1566
- return _ref.apply(this, arguments);
1567
- };
1568
- }();
1569
- this.completionCacheManager = createCompletionCacheManager(getFromLanguageService);
1570
- }
1571
- return _createClass(CompletionAdapter, [{
1572
- key: "triggerCharacters",
1573
- get: function get() {
1574
- return [' ', '.', '('];
1575
- }
1576
- }, {
1577
- key: "provideCompletionItems",
1578
- value: function provideCompletionItems(model, position, context, token) {
1579
- var _model$getWordAtPosit,
1580
- _this7 = this;
1581
- var wordInfo = model.getWordUntilPosition(position);
1582
- var wordRange = new monaco__namespace.Range(position.lineNumber, wordInfo.startColumn, position.lineNumber, wordInfo.endColumn);
1583
- var resource = model.uri;
1584
- var userInput = model === null || model === void 0 || (_model$getWordAtPosit = model.getWordAtPosition(position)) === null || _model$getWordAtPosit === void 0 ? void 0 : _model$getWordAtPosit.word;
1585
- var onDidProvideCompletionItems = this.languageSettings.onDidProvideCompletionItems;
1586
- return this.completionCacheManager.getCompletionItems(userInput, resource, fromPosition(position)).then(function (info) {
1587
- return onDidProvideCompletionItems ? onDidProvideCompletionItems(info) : info;
1588
- }).then(function (info) {
1589
- if (!info) return;
1590
- var selectedItem = getFocusedItem(info.items, userInput);
1591
- var items = info.items.map(function (entry, index) {
1592
- var _entry$documentation;
1593
- var item = {
1594
- label: entry.label,
1595
- insertText: entry.insertText,
1596
- sortText: entry.sortText,
1597
- filterText: createCompletionFilteredText(userInput, entry),
1598
- // TODO: Is this cast safe?
1599
- documentation: _this7.formatDocLink((_entry$documentation = entry.documentation) === null || _entry$documentation === void 0 ? void 0 : _entry$documentation.value),
1600
- detail: entry.detail,
1601
- range: wordRange,
1602
- kind: toCompletionItemKind(entry.kind),
1603
- preselect: selectedItem.filterText === entry.filterText
1604
- };
1605
- if (entry.textEdit) {
1606
- // TODO: Where is the "range" property coming from?
1607
- item.range = toRange(entry.textEdit.range);
1608
- item.insertText = entry.textEdit.newText;
1609
- }
1610
- if (entry.insertTextFormat === main.InsertTextFormat.Snippet) {
1611
- item.insertTextRules = monaco__namespace.languages.CompletionItemInsertTextRule.InsertAsSnippet;
1612
- }
1613
- return item;
1614
- });
1615
- return {
1616
- incomplete: true,
1617
- suggestions: items
1618
- };
1619
- });
1620
- }
1621
- }, {
1622
- key: "formatDocLink",
1623
- value: function formatDocLink(docString) {
1624
- // If the docString is empty, we want to return undefined to prevent an empty documentation popup.
1625
- if (!docString) {
1626
- return undefined;
1627
- }
1628
- var _this$languageSetting = this.languageSettings,
1629
- _this$languageSetting2 = _this$languageSetting.documentationBaseUrl,
1630
- documentationBaseUrl = _this$languageSetting2 === void 0 ? DEFAULT_DOCS_BASE_URL : _this$languageSetting2,
1631
- documentationSuffix = _this$languageSetting.documentationSuffix;
1632
- var urisProxy = new Proxy({}, {
1633
- get: function get(_target, prop, _receiver) {
1634
- // The link comes with a postfix of ".md" that we want to remove
1635
- var url = prop.toString().replace('.md', '');
1636
- // Sometimes we get the link as a full URL. For example in the main doc link of the item
1637
- if (!url.startsWith('https')) {
1638
- url = "".concat(documentationBaseUrl, "/").concat(url);
1639
- }
1640
- var monacoUri = monaco__namespace.Uri.parse(url);
1641
- if (documentationSuffix) {
1642
- // We need to override the toString method to add the suffix, otherwise it gets encoded and page doesn't open
1643
- monacoUri.toString = function () {
1644
- return url + documentationSuffix;
1645
- };
1646
- }
1647
- return monacoUri;
1648
- }
1649
- });
1650
- return {
1651
- value: docString,
1652
- isTrusted: true,
1653
- uris: urisProxy
1654
- };
1655
- }
1656
- }]);
1657
- }();
1658
- function isMarkupContent(thing) {
1659
- return thing && _typeof$1(thing) === 'object' && typeof thing.kind === 'string';
1660
- }
1661
- function toMarkdownString(entry) {
1662
- if (typeof entry === 'string') {
1663
- return {
1664
- value: entry
1665
- };
1666
- }
1667
- if (isMarkupContent(entry)) {
1668
- if (entry.kind === 'plaintext') {
1669
- return {
1670
- value: entry.value.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&')
1671
- };
1672
- }
1673
- return {
1674
- value: entry.value
1675
- };
1676
- }
1677
- return {
1678
- value: '```' + entry.value + '\n' + entry.value + '\n```\n'
1679
- };
1680
- }
1681
- function toMarkedStringArray(contents) {
1682
- if (!contents) {
1683
- return void 0;
1684
- }
1685
- if (Array.isArray(contents)) {
1686
- return contents.map(toMarkdownString);
1687
- }
1688
- return [toMarkdownString(contents)];
1689
- }
1690
-
1691
- // --- definition ------
1692
-
1693
- function toLocation(location) {
1694
- return {
1695
- uri: monaco__namespace.Uri.parse(location.uri),
1696
- range: toRange(location.range)
1697
- };
1698
- }
1699
- var DefinitionAdapter = /*#__PURE__*/function () {
1700
- function DefinitionAdapter(_worker) {
1701
- _classCallCheck(this, DefinitionAdapter);
1702
- this._worker = _worker;
1703
- }
1704
- return _createClass(DefinitionAdapter, [{
1705
- key: "provideDefinition",
1706
- value: function provideDefinition(model, position, token) {
1707
- var resource = model.uri;
1708
- return this._worker(resource).then(function (worker) {
1709
- return worker.findDefinition(resource.toString(), fromPosition(position));
1710
- }).then(function (definition) {
1711
- if (!definition || definition.length == 0) {
1712
- return;
1713
- }
1714
- return [toLocation(definition[0])];
1715
- });
1716
- }
1717
- }]);
1718
- }();
1719
-
1720
- // --- references ------
1721
-
1722
- var ReferenceAdapter = /*#__PURE__*/function () {
1723
- function ReferenceAdapter(_worker) {
1724
- _classCallCheck(this, ReferenceAdapter);
1725
- this._worker = _worker;
1726
- }
1727
- return _createClass(ReferenceAdapter, [{
1728
- key: "provideReferences",
1729
- value: function provideReferences(model, position, context, token) {
1730
- var resource = model.uri;
1731
- return this._worker(resource).then(function (worker) {
1732
- return worker.findReferences(resource.toString(), fromPosition(position));
1733
- }).then(function (entries) {
1734
- if (!entries) {
1735
- return;
1736
- }
1737
- return entries.map(toLocation);
1738
- });
1739
- }
1740
- }]);
1741
- }();
1742
-
1743
- // --- rename ------
1744
-
1745
- function toWorkspaceEdit(edit) {
1746
- if (!edit || !edit.changes) {
1747
- return void 0;
1748
- }
1749
- var resourceEdits = [];
1750
- for (var uri in edit.changes) {
1751
- var _uri = monaco__namespace.Uri.parse(uri);
1752
- var _iterator = _createForOfIteratorHelper(edit.changes[uri]),
1753
- _step;
1754
- try {
1755
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
1756
- var _e = _step.value;
1757
- resourceEdits.push({
1758
- resource: _uri,
1759
- textEdit: {
1760
- range: toRange(_e.range),
1761
- text: _e.newText
1762
- },
1763
- versionId: undefined
1764
- });
1765
- }
1766
- } catch (err) {
1767
- _iterator.e(err);
1768
- } finally {
1769
- _iterator.f();
1770
- }
1771
- }
1772
- return {
1773
- edits: resourceEdits
1774
- };
1775
- }
1776
- var RenameAdapter = /*#__PURE__*/function () {
1777
- function RenameAdapter(_worker) {
1778
- _classCallCheck(this, RenameAdapter);
1779
- this._worker = _worker;
1780
- }
1781
- return _createClass(RenameAdapter, [{
1782
- key: "provideRenameEdits",
1783
- value: function provideRenameEdits(model, position, newName, token) {
1784
- var resource = model.uri;
1785
- return this._worker(resource).then(function (worker) {
1786
- return worker.doRename(resource.toString(), fromPosition(position), newName);
1787
- }).then(function (edit) {
1788
- return toWorkspaceEdit(edit);
1789
- });
1790
- }
1791
- }]);
1792
- }();
1793
-
1794
- // --- formatting -----
1795
-
1796
- var DocumentFormatAdapter = /*#__PURE__*/function () {
1797
- function DocumentFormatAdapter(_worker) {
1798
- _classCallCheck(this, DocumentFormatAdapter);
1799
- this._worker = _worker;
1800
- }
1801
- return _createClass(DocumentFormatAdapter, [{
1802
- key: "provideDocumentFormattingEdits",
1803
- value: function provideDocumentFormattingEdits(model, options, token) {
1804
- var resource = model.uri;
1805
- return this._worker(resource).then(function (worker) {
1806
- return worker.doDocumentFormat(resource.toString()).then(function (edits) {
1807
- return edits.map(function (edit) {
1808
- return toTextEdit(edit);
1809
- });
1810
- });
1811
- });
1812
- }
1813
- }]);
1814
- }();
1815
- var FormatAdapter = /*#__PURE__*/function () {
1816
- function FormatAdapter(_worker) {
1817
- _classCallCheck(this, FormatAdapter);
1818
- this._worker = _worker;
1819
- }
1820
- return _createClass(FormatAdapter, [{
1821
- key: "provideDocumentRangeFormattingEdits",
1822
- value: function provideDocumentRangeFormattingEdits(model, range, options, token) {
1823
- var resource = model.uri;
1824
- return this._worker(resource).then(function (worker) {
1825
- return worker.doRangeFormat(resource.toString(), fromRange(range)).then(function (edits) {
1826
- return edits.map(function (edit) {
1827
- return toTextEdit(edit);
1828
- });
1829
- });
1830
- });
1831
- }
1832
- }]);
1833
- }();
1834
-
1835
- // --- Folding ---
1836
- var FoldingAdapter = /*#__PURE__*/function () {
1837
- function FoldingAdapter(_worker) {
1838
- _classCallCheck(this, FoldingAdapter);
1839
- this._worker = _worker;
1840
- }
1841
- return _createClass(FoldingAdapter, [{
1842
- key: "provideFoldingRanges",
1843
- value: function provideFoldingRanges(model, context, token) {
1844
- var resource = model.uri;
1845
- return this._worker(resource).then(function (worker) {
1846
- return worker.doFolding(resource.toString()).then(function (foldingRanges) {
1847
- return foldingRanges.map(function (range) {
1848
- return toFoldingRange(range);
1849
- });
1850
- });
1851
- });
1852
- }
1853
- }]);
1854
- }();
1855
- function toFoldingRange(range) {
1856
- return {
1857
- start: range.startLine + 1,
1858
- end: range.endLine + 1,
1859
- kind: monaco__namespace.languages.FoldingRangeKind.Region
1860
- };
1861
- }
1862
-
1863
- // --- hover ------
1864
-
1865
- var HoverAdapter = /*#__PURE__*/function () {
1866
- function HoverAdapter(_worker) {
1867
- _classCallCheck(this, HoverAdapter);
1868
- this._worker = _worker;
1869
- }
1870
- return _createClass(HoverAdapter, [{
1871
- key: "provideHover",
1872
- value: function provideHover(model, position, token) {
1873
- var resource = model.uri;
1874
- return this._worker(resource).then(function (worker) {
1875
- return worker.doHover(resource.toString(), fromPosition(position));
1876
- }).then(function (info) {
1877
- if (!info) {
1878
- return;
1879
- }
1880
- return {
1881
- range: toRange(info.range),
1882
- contents: toMarkedStringArray(info.contents)
1883
- };
1884
- });
1885
- }
1886
- }]);
1887
- }();
1888
-
1889
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
1890
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1891
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1892
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
1893
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
1894
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
1895
- function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
1896
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1897
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
1898
- function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
1899
- function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
1900
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
1901
- function _regeneratorRuntime() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
1902
- function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
1903
- function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
1904
- var kustoWorker;
1905
- var resolveWorker;
1906
- var workerPromise = new Promise(function (resolve, reject) {
1907
- resolveWorker = resolve;
1908
- });
1909
-
1910
- /**
1911
- * Called when Kusto language is first needed (a model has the language set)
1912
- * @param defaults
1913
- */
1914
- function setupMode(defaults, monacoInstance) {
1915
- var onSchemaChange = new monaco__namespace.Emitter();
1916
- // TODO: when should we dispose of these? seems like monaco-css and monaco-typescript don't dispose of these.
1917
- var disposables = [];
1918
- var monarchTokensProvider;
1919
- var client = new WorkerManager(monacoInstance, defaults);
1920
- disposables.push(client);
1921
- var workerAccessor = function workerAccessor(first) {
1922
- var augmentedSetSchema = /*#__PURE__*/function () {
1923
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(schema, worker) {
1924
- var workerPromise;
1925
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1926
- while (1) switch (_context.prev = _context.next) {
1927
- case 0:
1928
- workerPromise = worker.setSchema(schema);
1929
- _context.next = 3;
1930
- return workerPromise.then(function () {
1931
- onSchemaChange.fire(schema);
1932
- });
1933
- case 3:
1934
- case "end":
1935
- return _context.stop();
1936
- }
1937
- }, _callee);
1938
- }));
1939
- return function augmentedSetSchema(_x, _x2) {
1940
- return _ref.apply(this, arguments);
1941
- };
1942
- }();
1943
- for (var _len = arguments.length, more = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1944
- more[_key - 1] = arguments[_key];
1945
- }
1946
- var worker = client.getLanguageServiceWorker.apply(client, _toConsumableArray([first].concat(more)));
1947
- return worker.then(function (worker) {
1948
- return _objectSpread(_objectSpread({}, worker), {}, {
1949
- setSchema: function setSchema(schema) {
1950
- return augmentedSetSchema(schema, worker);
1951
- },
1952
- setSchemaFromShowSchema: function setSchemaFromShowSchema(schema, connection, database, globalScalarParameters, globalTabularParameters) {
1953
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
1954
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1955
- while (1) switch (_context2.prev = _context2.next) {
1956
- case 0:
1957
- _context2.next = 2;
1958
- return worker.normalizeSchema(schema, connection, database).then(function (schema) {
1959
- if (globalScalarParameters || globalTabularParameters) {
1960
- schema = _objectSpread(_objectSpread({}, schema), {}, {
1961
- globalScalarParameters: globalScalarParameters,
1962
- globalTabularParameters: globalTabularParameters
1963
- });
1964
- }
1965
- augmentedSetSchema(schema, worker);
1966
- });
1967
- case 2:
1968
- case "end":
1969
- return _context2.stop();
1970
- }
1971
- }, _callee2);
1972
- }))();
1973
- }
1974
- });
1975
- });
1976
- };
1977
- var language = 'kusto';
1978
- disposables.push(monacoInstance.languages.registerCompletionItemProvider(language, new CompletionAdapter(workerAccessor, defaults.languageSettings)));
1979
-
1980
- // Monaco tokenization runs in main thread so we're using a quick schema-unaware tokenization.
1981
- // a web worker will run semantic colorization in the background (ColorizationAdapter).
1982
- if (defaults.languageSettings.useTokenColorization) {
1983
- monarchTokensProvider = monacoInstance.languages.setMonarchTokensProvider(language, KustoLanguageDefinition);
1984
- }
1985
-
1986
- // listen to configuration changes and if we're switching from semantic to monarch colorization, do the switch.
1987
- defaults.onDidChange(function (e) {
1988
- if (!e.languageSettings.useTokenColorization && monarchTokensProvider !== undefined) {
1989
- monarchTokensProvider.dispose();
1990
- monarchTokensProvider = undefined;
1991
- }
1992
- if (e.languageSettings.useTokenColorization && monarchTokensProvider == undefined) {
1993
- monarchTokensProvider = monacoInstance.languages.setMonarchTokensProvider(language, KustoLanguageDefinition);
1994
- }
1995
- });
1996
- disposables.push(new DiagnosticsAdapter(monacoInstance, language, workerAccessor, defaults, onSchemaChange.event));
1997
- disposables.push(new ColorizationAdapter(monacoInstance, language, workerAccessor, defaults, onSchemaChange.event));
1998
- disposables.push(monacoInstance.languages.registerDocumentRangeFormattingEditProvider(language, new FormatAdapter(workerAccessor)));
1999
- disposables.push(monacoInstance.languages.registerFoldingRangeProvider(language, new FoldingAdapter(workerAccessor)));
2000
- disposables.push(monacoInstance.languages.registerDefinitionProvider(language, new DefinitionAdapter(workerAccessor)));
2001
- disposables.push(monacoInstance.languages.registerRenameProvider(language, new RenameAdapter(workerAccessor)));
2002
- disposables.push(monacoInstance.languages.registerReferenceProvider(language, new ReferenceAdapter(workerAccessor)));
2003
- if (defaults.languageSettings.enableHover) {
2004
- disposables.push(monacoInstance.languages.registerHoverProvider(language, new HoverAdapter(workerAccessor)));
2005
- }
2006
- monacoInstance.languages.registerDocumentFormattingEditProvider(language, new DocumentFormatAdapter(workerAccessor));
2007
- kustoWorker = workerAccessor;
2008
- resolveWorker(workerAccessor);
2009
- monacoInstance.languages.setLanguageConfiguration(language, {
2010
- folding: {
2011
- offSide: false,
2012
- markers: {
2013
- start: /^\s*[\r\n]/gm,
2014
- end: /^\s*[\r\n]/gm
2015
- }
2016
- },
2017
- comments: {
2018
- lineComment: '//',
2019
- blockComment: null
2020
- },
2021
- autoClosingPairs: [{
2022
- open: '{',
2023
- close: '}'
2024
- }, {
2025
- open: '[',
2026
- close: ']'
2027
- }, {
2028
- open: '(',
2029
- close: ')'
2030
- }, {
2031
- open: "'",
2032
- close: "'",
2033
- notIn: ['string', 'comment']
2034
- }, {
2035
- open: '"',
2036
- close: '"',
2037
- notIn: ['string', 'comment']
2038
- }]
2039
- });
2040
- return kustoWorker;
2041
- }
2042
- function getKustoWorker() {
2043
- return workerPromise.then(function () {
2044
- return kustoWorker;
2045
- });
2046
- }
2047
-
2048
- exports.getKustoWorker = getKustoWorker;
2049
- exports.setupMode = setupMode;
12
+ exports.getKustoWorker = kustoMode.getKustoWorker;
13
+ exports.setupMode = kustoMode.setupMode;
2050
14
 
2051
15
  }));