@kusto/monaco-kusto 11.0.0 → 11.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -4
- package/package.json +4 -2
- package/release/dev/Kusto.Language.Bridge.min.js +193 -190
- package/release/dev/kustoMode.js +106 -76
- package/release/dev/kustoWorker.js +84 -57
- package/release/dev/{main-89eef687.js → main-326a932b.js} +8 -9
- package/release/dev/monaco.contribution.js +22 -24
- package/release/dev/{schema-d4b2563b.js → schema-26bd7933.js} +2 -2
- package/release/esm/completionCacheManager/completionCacheManager.d.ts +7 -0
- package/release/esm/completionCacheManager/completionCacheManager.js +14 -0
- package/release/esm/kusto.worker.js +28 -3
- package/release/esm/languageFeatures.d.ts +3 -3
- package/release/esm/languageFeatures.js +26 -13
- package/release/esm/languageFeatures.utils.d.ts +2 -0
- package/release/esm/languageFeatures.utils.js +7 -0
- package/release/esm/languageServiceManager/competionItemSort.d.ts +3 -0
- package/release/esm/languageServiceManager/competionItemSort.js +22 -0
- package/release/esm/languageServiceManager/kustoLanguageService.d.ts +2 -2
- package/release/esm/languageServiceManager/kustoLanguageService.js +9 -7
- package/release/esm/languageServiceManager/kustoMonarchLanguageDefinition.js +1 -1
- package/release/esm/monaco.contribution.js +31 -31
- package/release/esm/{schema-390a6d13.js → schema-33d2a0bc.js} +1 -1
- package/release/min/Kusto.Language.Bridge.min.js +193 -190
- package/release/min/kustoMode.js +2 -2
- package/release/min/kustoWorker.js +4 -4
- package/release/min/main-af2fa57f.js +7 -0
- package/release/min/monaco.contribution.js +2 -2
- package/release/min/{schema-c597d265.js → schema-9f26f1e2.js} +2 -2
- package/release/min/main-42d8da0e.js +0 -7
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!-----------------------------------------------------------------------------
|
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* monaco-kusto version: 11.
|
|
3
|
+
* monaco-kusto version: 11.1.0(a4f4a803b61d72aca89d2412b0c7849259e4fd91)
|
|
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/monaco.contribution', ['require', 'exports', 'vs/editor/editor.main', './schema-
|
|
8
|
+
define('vs/language/kusto/monaco.contribution', ['require', 'exports', 'vs/editor/editor.main', './schema-26bd7933'], (function (require, exports, monaco, schema) { 'use strict';
|
|
9
9
|
|
|
10
10
|
function _interopNamespaceDefault(e) {
|
|
11
11
|
var n = Object.create(null);
|
|
@@ -77,12 +77,12 @@ define('vs/language/kusto/monaco.contribution', ['require', 'exports', 'vs/edito
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
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); }
|
|
80
|
-
function _classCallCheck$2(
|
|
81
|
-
function _defineProperties$2(
|
|
82
|
-
function _createClass$2(
|
|
83
|
-
function _defineProperty$2(
|
|
84
|
-
function _toPropertyKey$2(
|
|
85
|
-
function _toPrimitive$2(
|
|
80
|
+
function _classCallCheck$2(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
81
|
+
function _defineProperties$2(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); } }
|
|
82
|
+
function _createClass$2(e, r, t) { return r && _defineProperties$2(e.prototype, r), t && _defineProperties$2(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
83
|
+
function _defineProperty$2(e, r, t) { return (r = _toPropertyKey$2(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
84
|
+
function _toPropertyKey$2(t) { var i = _toPrimitive$2(t, "string"); return "symbol" == _typeof$2(i) ? i : i + ""; }
|
|
85
|
+
function _toPrimitive$2(t, r) { if ("object" != _typeof$2(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof$2(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
88
|
* Highlights the command that surround cursor location
|
|
@@ -107,7 +107,7 @@ define('vs/language/kusto/monaco.contribution', ['require', 'exports', 'vs/edito
|
|
|
107
107
|
_this.highlightCommandUnderCursor(changeEvent);
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
-
_createClass$2(KustoCommandHighlighter, [{
|
|
110
|
+
return _createClass$2(KustoCommandHighlighter, [{
|
|
111
111
|
key: "getId",
|
|
112
112
|
value: function getId() {
|
|
113
113
|
return KustoCommandHighlighter.ID;
|
|
@@ -136,7 +136,6 @@ define('vs/language/kusto/monaco.contribution', ['require', 'exports', 'vs/edito
|
|
|
136
136
|
this.decorations = this.editor.deltaDecorations(this.decorations, decorations);
|
|
137
137
|
}
|
|
138
138
|
}]);
|
|
139
|
-
return KustoCommandHighlighter;
|
|
140
139
|
}();
|
|
141
140
|
_defineProperty$2(KustoCommandHighlighter, "ID", 'editor.contrib.kustoCommandHighlighter');
|
|
142
141
|
_defineProperty$2(KustoCommandHighlighter, "CURRENT_COMMAND_HIGHLIGHT", {
|
|
@@ -144,12 +143,12 @@ define('vs/language/kusto/monaco.contribution', ['require', 'exports', 'vs/edito
|
|
|
144
143
|
});
|
|
145
144
|
|
|
146
145
|
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); }
|
|
147
|
-
function _defineProperties$1(
|
|
148
|
-
function _createClass$1(
|
|
149
|
-
function _classCallCheck$1(
|
|
150
|
-
function _defineProperty$1(
|
|
151
|
-
function _toPropertyKey$1(
|
|
152
|
-
function _toPrimitive$1(
|
|
146
|
+
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$1(o.key), o); } }
|
|
147
|
+
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; }
|
|
148
|
+
function _classCallCheck$1(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
149
|
+
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; }
|
|
150
|
+
function _toPropertyKey$1(t) { var i = _toPrimitive$1(t, "string"); return "symbol" == _typeof$1(i) ? i : i + ""; }
|
|
151
|
+
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); }
|
|
153
152
|
var KustoCommandFormatter = /*#__PURE__*/_createClass$1(function KustoCommandFormatter(editor) {
|
|
154
153
|
var _this = this;
|
|
155
154
|
_classCallCheck$1(this, KustoCommandFormatter);
|
|
@@ -183,12 +182,12 @@ define('vs/language/kusto/monaco.contribution', ['require', 'exports', 'vs/edito
|
|
|
183
182
|
});
|
|
184
183
|
|
|
185
184
|
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); }
|
|
186
|
-
function _classCallCheck(
|
|
187
|
-
function _defineProperties(
|
|
188
|
-
function _createClass(
|
|
189
|
-
function _defineProperty(
|
|
190
|
-
function _toPropertyKey(
|
|
191
|
-
function _toPrimitive(
|
|
185
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
186
|
+
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(o.key), o); } }
|
|
187
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
188
|
+
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; }
|
|
189
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
190
|
+
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); }
|
|
192
191
|
|
|
193
192
|
// --- Kusto configuration and defaults ---------
|
|
194
193
|
var LanguageServiceDefaultsImpl = /*#__PURE__*/function () {
|
|
@@ -206,7 +205,7 @@ define('vs/language/kusto/monaco.contribution', ['require', 'exports', 'vs/edito
|
|
|
206
205
|
// setSchema. That way we don't need to stringify the schema on the worker side when killing the web worker.
|
|
207
206
|
this._workerMaxIdleTime = 0;
|
|
208
207
|
}
|
|
209
|
-
_createClass(LanguageServiceDefaultsImpl, [{
|
|
208
|
+
return _createClass(LanguageServiceDefaultsImpl, [{
|
|
210
209
|
key: "onDidChange",
|
|
211
210
|
get: function get() {
|
|
212
211
|
return this._onDidChange.event;
|
|
@@ -235,7 +234,6 @@ define('vs/language/kusto/monaco.contribution', ['require', 'exports', 'vs/edito
|
|
|
235
234
|
return this._workerMaxIdleTime;
|
|
236
235
|
}
|
|
237
236
|
}]);
|
|
238
|
-
return LanguageServiceDefaultsImpl;
|
|
239
237
|
}();
|
|
240
238
|
var defaultLanguageSettings = {
|
|
241
239
|
includeControlCommands: true,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!-----------------------------------------------------------------------------
|
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* monaco-kusto version: 11.
|
|
3
|
+
* monaco-kusto version: 11.1.0(a4f4a803b61d72aca89d2412b0c7849259e4fd91)
|
|
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/schema-
|
|
8
|
+
define('vs/language/kusto/schema-26bd7933', ['exports'], (function (exports) { 'use strict';
|
|
9
9
|
|
|
10
10
|
// Definition of schema object in the context of language services. This model is exposed to consumers of this library.
|
|
11
11
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
|
2
|
+
import * as ls from 'vscode-languageserver-types';
|
|
3
|
+
export declare const createCompletionCacheManager: (getFromLanguageService: GetFromLanguageService) => {
|
|
4
|
+
getCompletionItems: (word: string | undefined, resource: monaco.Uri, position: ls.Position) => Promise<ls.CompletionList>;
|
|
5
|
+
};
|
|
6
|
+
export type CompletionCacheManager = ReturnType<typeof createCompletionCacheManager>;
|
|
7
|
+
export type GetFromLanguageService = (resource: monaco.Uri, position: ls.Position) => Promise<ls.CompletionList>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export var createCompletionCacheManager = function (getFromLanguageService) {
|
|
2
|
+
var completionList;
|
|
3
|
+
var lastWord;
|
|
4
|
+
return {
|
|
5
|
+
getCompletionItems: function (word, resource, position) {
|
|
6
|
+
var shouldGetItems = !lastWord || !word || !(word === null || word === void 0 ? void 0 : word.includes(lastWord));
|
|
7
|
+
if (shouldGetItems) {
|
|
8
|
+
completionList = getFromLanguageService(resource, position);
|
|
9
|
+
}
|
|
10
|
+
lastWord = word;
|
|
11
|
+
return completionList;
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!-----------------------------------------------------------------------------
|
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* monaco-kusto version: 11.
|
|
3
|
+
* monaco-kusto version: 11.1.0(a4f4a803b61d72aca89d2412b0c7849259e4fd91)
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://https://github.com/Azure/monaco-kusto/blob/master/README.md
|
|
6
6
|
*-----------------------------------------------------------------------------*/
|
|
@@ -8,15 +8,36 @@
|
|
|
8
8
|
import * as worker from 'monaco-editor/esm/vs/editor/editor.worker';
|
|
9
9
|
import * as ls from 'vscode-languageserver-types';
|
|
10
10
|
import XRegExp from 'xregexp';
|
|
11
|
-
import { d as getEntityDataTypeFromCslType, a as getCallName, b as getExpression, g as getCslTypeNameFromClrType } from './schema-
|
|
11
|
+
import { d as getEntityDataTypeFromCslType, a as getCallName, b as getExpression, g as getCslTypeNameFromClrType } from './schema-33d2a0bc.js';
|
|
12
12
|
import '@kusto/language-service/bridge.min';
|
|
13
13
|
import '@kusto/language-service/Kusto.JavaScript.Client.min';
|
|
14
14
|
import '@kusto/language-service/newtonsoft.json.min';
|
|
15
15
|
import '@kusto/language-service-next/Kusto.Language.Bridge.min';
|
|
16
16
|
|
|
17
|
+
Kusto.Language.Editor;
|
|
17
18
|
const createSortingText = priority => {
|
|
18
19
|
return priority.toString().padStart(10, '0');
|
|
19
20
|
};
|
|
21
|
+
function sortByMatchTextKeepingKindOrder(items) {
|
|
22
|
+
const groupedByKind = groupContiguousByKind(items);
|
|
23
|
+
const sortedGroupedItems = sortGroupedItems(groupedByKind);
|
|
24
|
+
return sortedGroupedItems.flat();
|
|
25
|
+
}
|
|
26
|
+
function sortGroupedItems(groupedItems) {
|
|
27
|
+
return groupedItems.map(group => group.sort((i1, i2) => i1.MatchText.localeCompare(i2.MatchText)));
|
|
28
|
+
}
|
|
29
|
+
function groupContiguousByKind(items) {
|
|
30
|
+
return items.reduce((result, item) => {
|
|
31
|
+
const lastGroup = last(result);
|
|
32
|
+
const shouldCreateNewGroup = !lastGroup || last(lastGroup)?.Kind !== item.Kind;
|
|
33
|
+
if (shouldCreateNewGroup) result.push([]);
|
|
34
|
+
last(result).push(item);
|
|
35
|
+
return result;
|
|
36
|
+
}, []);
|
|
37
|
+
}
|
|
38
|
+
function last(array) {
|
|
39
|
+
return array.length > 0 ? array[array.length - 1] : undefined;
|
|
40
|
+
}
|
|
20
41
|
|
|
21
42
|
var k = Kusto.Data.IntelliSense;
|
|
22
43
|
var parsing = Kusto.Language.Parsing;
|
|
@@ -284,7 +305,8 @@ class KustoLanguageService {
|
|
|
284
305
|
});
|
|
285
306
|
}
|
|
286
307
|
const itemsAsArray = this.toArray(completionItems.Items);
|
|
287
|
-
|
|
308
|
+
const sortedArray = sortByMatchTextKeepingKindOrder(itemsAsArray);
|
|
309
|
+
let items = sortedArray.filter(item => !(item && item.MatchText && disabledItems[item.MatchText] !== undefined && (disabledItems[item.MatchText] === k2.CompletionKind.Unknown || disabledItems[item.MatchText] === item.Kind))).map((kItem, index) => {
|
|
288
310
|
const v1CompletionOption = new k.CompletionOption(this._toOptionKind[kItem.Kind] || k.OptionKind.None, kItem.DisplayText);
|
|
289
311
|
const helpTopic = this.getTopic(v1CompletionOption);
|
|
290
312
|
// If we have AfterText it means that the cursor should not be placed at end of suggested text.
|
|
@@ -316,6 +338,9 @@ class KustoLanguageService {
|
|
|
316
338
|
value: this.formatHelpTopic(helpTopic),
|
|
317
339
|
kind: ls.MarkupKind.Markdown
|
|
318
340
|
} : undefined;
|
|
341
|
+
lsItem.data = {
|
|
342
|
+
forcePrecedence: kItem.Kind === k2.CompletionKind.Column
|
|
343
|
+
};
|
|
319
344
|
return lsItem;
|
|
320
345
|
});
|
|
321
346
|
return Promise.resolve(ls.CompletionList.create(items));
|
|
@@ -33,9 +33,9 @@ export declare class ColorizationAdapter {
|
|
|
33
33
|
private _doColorization;
|
|
34
34
|
}
|
|
35
35
|
export declare class CompletionAdapter implements monaco.languages.CompletionItemProvider {
|
|
36
|
-
private
|
|
37
|
-
private
|
|
38
|
-
constructor(
|
|
36
|
+
private readonly languageSettings;
|
|
37
|
+
private completionCacheManager;
|
|
38
|
+
constructor(workerAccessor: AugmentedWorkerAccessor, languageSettings: LanguageSettings);
|
|
39
39
|
get triggerCharacters(): string[];
|
|
40
40
|
provideCompletionItems(model: monaco.editor.IReadOnlyModel, position: monaco.Position, context: monaco.languages.CompletionContext, token: monaco.CancellationToken): monaco.Thenable<monaco.languages.CompletionList>;
|
|
41
41
|
private formatDocLink;
|
|
@@ -46,6 +46,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
46
46
|
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
|
47
47
|
import * as ls from 'vscode-languageserver-types';
|
|
48
48
|
import debounce from 'lodash-es/debounce';
|
|
49
|
+
import { createCompletionCacheManager } from './completionCacheManager/completionCacheManager';
|
|
50
|
+
import { createCompletionFilteredText } from './languageFeatures.utils';
|
|
49
51
|
var DiagnosticsAdapter = /** @class */ (function () {
|
|
50
52
|
function DiagnosticsAdapter(_monacoInstance, _languageId, _worker, defaults, onSchemaChange) {
|
|
51
53
|
var _this = this;
|
|
@@ -167,9 +169,9 @@ var DiagnosticsAdapter = /** @class */ (function () {
|
|
|
167
169
|
this._monacoInstance.editor.getEditors().forEach(onEditorAdd);
|
|
168
170
|
}
|
|
169
171
|
DiagnosticsAdapter.prototype.getMonacoCodeActions = function (model, startOffset, endOffset, enableQuickFix) {
|
|
170
|
-
var _a;
|
|
171
172
|
return __awaiter(this, void 0, void 0, function () {
|
|
172
173
|
var actions, worker, resource, codeActions, _loop_1, this_1, i, state_1;
|
|
174
|
+
var _a;
|
|
173
175
|
return __generator(this, function (_b) {
|
|
174
176
|
switch (_b.label) {
|
|
175
177
|
case 0:
|
|
@@ -291,8 +293,8 @@ var DiagnosticsAdapter = /** @class */ (function () {
|
|
|
291
293
|
hoverMessage: {
|
|
292
294
|
value: popupErrorHoverHeaderMessage_1 + marker.message,
|
|
293
295
|
},
|
|
294
|
-
className: 'squiggly-error',
|
|
295
|
-
zIndex: 100,
|
|
296
|
+
className: 'squiggly-error', // monaco syntax error style (red underline)
|
|
297
|
+
zIndex: 100, // This message will be the upper most mesage in the popup
|
|
296
298
|
overviewRuler: {
|
|
297
299
|
// The color indication on the right ruler
|
|
298
300
|
color: 'rgb(255, 18, 18, 0.7)',
|
|
@@ -731,9 +733,21 @@ function toTextEdit(textEdit) {
|
|
|
731
733
|
}
|
|
732
734
|
var DEFAULT_DOCS_BASE_URL = 'https://learn.microsoft.com/azure/data-explorer/kusto/query';
|
|
733
735
|
var CompletionAdapter = /** @class */ (function () {
|
|
734
|
-
function CompletionAdapter(
|
|
735
|
-
|
|
736
|
+
function CompletionAdapter(workerAccessor, languageSettings) {
|
|
737
|
+
var _this = this;
|
|
736
738
|
this.languageSettings = languageSettings;
|
|
739
|
+
var getFromLanguageService = function (resource, position) { return __awaiter(_this, void 0, void 0, function () {
|
|
740
|
+
var worker;
|
|
741
|
+
return __generator(this, function (_a) {
|
|
742
|
+
switch (_a.label) {
|
|
743
|
+
case 0: return [4 /*yield*/, workerAccessor(resource)];
|
|
744
|
+
case 1:
|
|
745
|
+
worker = _a.sent();
|
|
746
|
+
return [2 /*return*/, worker.doComplete(resource.toString(), position)];
|
|
747
|
+
}
|
|
748
|
+
});
|
|
749
|
+
}); };
|
|
750
|
+
this.completionCacheManager = createCompletionCacheManager(getFromLanguageService);
|
|
737
751
|
}
|
|
738
752
|
Object.defineProperty(CompletionAdapter.prototype, "triggerCharacters", {
|
|
739
753
|
get: function () {
|
|
@@ -744,26 +758,25 @@ var CompletionAdapter = /** @class */ (function () {
|
|
|
744
758
|
});
|
|
745
759
|
CompletionAdapter.prototype.provideCompletionItems = function (model, position, context, token) {
|
|
746
760
|
var _this = this;
|
|
761
|
+
var _a;
|
|
747
762
|
var wordInfo = model.getWordUntilPosition(position);
|
|
748
763
|
var wordRange = new monaco.Range(position.lineNumber, wordInfo.startColumn, position.lineNumber, wordInfo.endColumn);
|
|
749
764
|
var resource = model.uri;
|
|
765
|
+
var word = (_a = model === null || model === void 0 ? void 0 : model.getWordAtPosition(position)) === null || _a === void 0 ? void 0 : _a.word;
|
|
750
766
|
var onDidProvideCompletionItems = this.languageSettings.onDidProvideCompletionItems;
|
|
751
|
-
return this.
|
|
752
|
-
.
|
|
753
|
-
return worker.doComplete(resource.toString(), fromPosition(position));
|
|
754
|
-
})
|
|
767
|
+
return this.completionCacheManager
|
|
768
|
+
.getCompletionItems(word, resource, fromPosition(position))
|
|
755
769
|
.then(function (info) { return (onDidProvideCompletionItems ? onDidProvideCompletionItems(info) : info); })
|
|
756
770
|
.then(function (info) {
|
|
757
|
-
if (!info)
|
|
771
|
+
if (!info)
|
|
758
772
|
return;
|
|
759
|
-
}
|
|
760
773
|
var items = info.items.map(function (entry) {
|
|
761
774
|
var _a;
|
|
762
775
|
var item = {
|
|
763
776
|
label: entry.label,
|
|
764
777
|
insertText: entry.insertText,
|
|
765
778
|
sortText: entry.sortText,
|
|
766
|
-
filterText: entry
|
|
779
|
+
filterText: createCompletionFilteredText(word, entry),
|
|
767
780
|
// TODO: Is this cast safe?
|
|
768
781
|
documentation: _this.formatDocLink((_a = entry.documentation) === null || _a === void 0 ? void 0 : _a.value),
|
|
769
782
|
detail: entry.detail,
|
|
@@ -781,7 +794,7 @@ var CompletionAdapter = /** @class */ (function () {
|
|
|
781
794
|
return item;
|
|
782
795
|
});
|
|
783
796
|
return {
|
|
784
|
-
|
|
797
|
+
incomplete: true,
|
|
785
798
|
suggestions: items,
|
|
786
799
|
};
|
|
787
800
|
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function createCompletionFilteredText(searchWord, completionItem) {
|
|
2
|
+
if (!searchWord)
|
|
3
|
+
return completionItem.filterText;
|
|
4
|
+
var containedInFilterText = completionItem.filterText.toLowerCase().includes(searchWord.toLowerCase());
|
|
5
|
+
var shouldPrependSearchWord = completionItem.data.forcePrecedence && containedInFilterText;
|
|
6
|
+
return shouldPrependSearchWord ? "".concat(searchWord).concat(completionItem.filterText) : completionItem.filterText;
|
|
7
|
+
}
|
|
@@ -1 +1,4 @@
|
|
|
1
|
+
/// <reference types="@kusto/language-service-next/Kusto.Language.Bridge" />
|
|
2
|
+
import k2 = Kusto.Language.Editor;
|
|
1
3
|
export declare const createSortingText: (priority: number) => string;
|
|
4
|
+
export declare function sortByMatchTextKeepingKindOrder(items: k2.CompletionItem[]): k2.CompletionItem[];
|
|
@@ -1,3 +1,25 @@
|
|
|
1
1
|
export var createSortingText = function (priority) {
|
|
2
2
|
return priority.toString().padStart(10, '0');
|
|
3
3
|
};
|
|
4
|
+
export function sortByMatchTextKeepingKindOrder(items) {
|
|
5
|
+
var groupedByKind = groupContiguousByKind(items);
|
|
6
|
+
var sortedGroupedItems = sortGroupedItems(groupedByKind);
|
|
7
|
+
return sortedGroupedItems.flat();
|
|
8
|
+
}
|
|
9
|
+
function sortGroupedItems(groupedItems) {
|
|
10
|
+
return groupedItems.map(function (group) { return group.sort(function (i1, i2) { return i1.MatchText.localeCompare(i2.MatchText); }); });
|
|
11
|
+
}
|
|
12
|
+
function groupContiguousByKind(items) {
|
|
13
|
+
return items.reduce(function (result, item) {
|
|
14
|
+
var _a;
|
|
15
|
+
var lastGroup = last(result);
|
|
16
|
+
var shouldCreateNewGroup = !lastGroup || ((_a = last(lastGroup)) === null || _a === void 0 ? void 0 : _a.Kind) !== item.Kind;
|
|
17
|
+
if (shouldCreateNewGroup)
|
|
18
|
+
result.push([]);
|
|
19
|
+
last(result).push(item);
|
|
20
|
+
return result;
|
|
21
|
+
}, []);
|
|
22
|
+
}
|
|
23
|
+
function last(array) {
|
|
24
|
+
return array.length > 0 ? array[array.length - 1] : undefined;
|
|
25
|
+
}
|
|
@@ -14,8 +14,8 @@ import type { ClusterReference, DatabaseReference } from '../types';
|
|
|
14
14
|
export declare enum TokenKind {
|
|
15
15
|
TableToken = 2,
|
|
16
16
|
TableColumnToken = 4,
|
|
17
|
-
OperatorToken = 8,
|
|
18
|
-
SubOperatorToken = 16,
|
|
17
|
+
OperatorToken = 8,// where, project, ...
|
|
18
|
+
SubOperatorToken = 16,// has, contains, ...
|
|
19
19
|
CalculatedColumnToken = 32,
|
|
20
20
|
StringLiteralToken = 64,
|
|
21
21
|
FunctionNameToken = 128,
|
|
@@ -41,7 +41,7 @@ var k2 = Kusto.Language.Editor;
|
|
|
41
41
|
var sym = Kusto.Language.Symbols;
|
|
42
42
|
var GlobalState = Kusto.Language.GlobalState;
|
|
43
43
|
import { getCslTypeNameFromClrType, getEntityDataTypeFromCslType } from './schema';
|
|
44
|
-
import { createSortingText } from './competionItemSort';
|
|
44
|
+
import { createSortingText, sortByMatchTextKeepingKindOrder } from './competionItemSort';
|
|
45
45
|
var List = System.Collections.Generic.List$1;
|
|
46
46
|
function assertNever(x) {
|
|
47
47
|
throw new Error('Unexpected object: ' + x);
|
|
@@ -269,13 +269,13 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
269
269
|
_d[TokenKind.CommentToken] = k2.ClassificationKind.Comment,
|
|
270
270
|
_d[TokenKind.PlainTextToken] = k2.ClassificationKind.PlainText,
|
|
271
271
|
_d[TokenKind.DataTypeToken] = k2.ClassificationKind.Type,
|
|
272
|
-
_d[TokenKind.ControlCommandToken] = k2.ClassificationKind.PlainText,
|
|
273
|
-
_d[TokenKind.CommandPartToken] = k2.ClassificationKind.PlainText,
|
|
272
|
+
_d[TokenKind.ControlCommandToken] = k2.ClassificationKind.PlainText, // TODO ?
|
|
273
|
+
_d[TokenKind.CommandPartToken] = k2.ClassificationKind.PlainText, // TODO ?
|
|
274
274
|
_d[TokenKind.QueryParametersToken] = k2.ClassificationKind.QueryParameter,
|
|
275
|
-
_d[TokenKind.CslCommandToken] = k2.ClassificationKind.Keyword,
|
|
276
|
-
_d[TokenKind.LetVariablesToken] = k2.ClassificationKind.Identifier,
|
|
275
|
+
_d[TokenKind.CslCommandToken] = k2.ClassificationKind.Keyword, // TODO ?
|
|
276
|
+
_d[TokenKind.LetVariablesToken] = k2.ClassificationKind.Identifier, // TODO ?
|
|
277
277
|
_d[TokenKind.PluginToken] = k2.ClassificationKind.Function,
|
|
278
|
-
_d[TokenKind.BracketRangeToken] = k2.ClassificationKind.Keyword,
|
|
278
|
+
_d[TokenKind.BracketRangeToken] = k2.ClassificationKind.Keyword, // TODO ?
|
|
279
279
|
_d[TokenKind.ClientDirectiveToken] = k2.ClassificationKind.Keyword,
|
|
280
280
|
_d);
|
|
281
281
|
this._schemaCache = {};
|
|
@@ -384,7 +384,8 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
384
384
|
});
|
|
385
385
|
}
|
|
386
386
|
var itemsAsArray = this.toArray(completionItems.Items);
|
|
387
|
-
var
|
|
387
|
+
var sortedArray = sortByMatchTextKeepingKindOrder(itemsAsArray);
|
|
388
|
+
var items = sortedArray
|
|
388
389
|
.filter(function (item) {
|
|
389
390
|
return !(item &&
|
|
390
391
|
item.MatchText &&
|
|
@@ -422,6 +423,7 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
422
423
|
lsItem.documentation = helpTopic
|
|
423
424
|
? { value: _this.formatHelpTopic(helpTopic), kind: ls.MarkupKind.Markdown }
|
|
424
425
|
: undefined;
|
|
426
|
+
lsItem.data = { forcePrecedence: kItem.Kind === k2.CompletionKind.Column };
|
|
425
427
|
return lsItem;
|
|
426
428
|
});
|
|
427
429
|
return Promise.resolve(ls.CompletionList.create(items));
|
|
@@ -6,7 +6,7 @@ export var KustoLanguageDefinition = {
|
|
|
6
6
|
brackets: [
|
|
7
7
|
['[', ']', 'delimiter.square'],
|
|
8
8
|
['(', ')', 'delimiter.parenthesis'],
|
|
9
|
-
],
|
|
9
|
+
], // types are wrong
|
|
10
10
|
wordDefinition: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
|
|
11
11
|
// .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.
|
|
12
12
|
// Kusto.Data.IntelliSense.CslCommandParser.PromotedOperatorCommandTokens.slice(0),
|
|
@@ -97,21 +97,21 @@ monaco.editor.defineTheme(themeNames.light, {
|
|
|
97
97
|
base: 'vs',
|
|
98
98
|
inherit: true,
|
|
99
99
|
rules: [
|
|
100
|
-
{ token: 'comment', foreground: '008000' },
|
|
101
|
-
{ token: 'variable.predefined', foreground: '800080' },
|
|
102
|
-
{ token: 'function', foreground: '0000FF' },
|
|
103
|
-
{ token: 'operator.sql', foreground: 'CC3700' },
|
|
104
|
-
{ token: 'string', foreground: 'B22222' },
|
|
105
|
-
{ token: 'operator.scss', foreground: '0000FF' },
|
|
106
|
-
{ token: 'variable', foreground: 'C71585' },
|
|
107
|
-
{ token: 'variable.parameter', foreground: '9932CC' },
|
|
108
|
-
{ token: '', foreground: '000000' },
|
|
109
|
-
{ token: 'type', foreground: '0000FF' },
|
|
110
|
-
{ token: 'tag', foreground: '0000FF' },
|
|
111
|
-
{ token: 'annotation', foreground: '2B91AF' },
|
|
112
|
-
{ token: 'keyword', foreground: '0000FF' },
|
|
113
|
-
{ token: 'number', foreground: '191970' },
|
|
114
|
-
{ token: 'annotation', foreground: '9400D3' },
|
|
100
|
+
{ token: 'comment', foreground: '008000' }, // CommentToken Green
|
|
101
|
+
{ token: 'variable.predefined', foreground: '800080' }, // CalculatedColumnToken Purple
|
|
102
|
+
{ token: 'function', foreground: '0000FF' }, // FunctionNameToken Blue
|
|
103
|
+
{ token: 'operator.sql', foreground: 'CC3700' }, // _WAS_ OperatorToken OrangeRed, but wasn't accessible.
|
|
104
|
+
{ token: 'string', foreground: 'B22222' }, // StringLiteralToken Firebrick
|
|
105
|
+
{ token: 'operator.scss', foreground: '0000FF' }, // SubOperatorToken Blue
|
|
106
|
+
{ token: 'variable', foreground: 'C71585' }, // TableColumnToken MediumVioletRed
|
|
107
|
+
{ token: 'variable.parameter', foreground: '9932CC' }, // TableToken DarkOrchid
|
|
108
|
+
{ token: '', foreground: '000000' }, // UnknownToken, PlainTextToken Black
|
|
109
|
+
{ token: 'type', foreground: '0000FF' }, // DataTypeToken Blue
|
|
110
|
+
{ token: 'tag', foreground: '0000FF' }, // ControlCommandToken Blue
|
|
111
|
+
{ token: 'annotation', foreground: '2B91AF' }, // QueryParametersToken FF2B91AF
|
|
112
|
+
{ token: 'keyword', foreground: '0000FF' }, // CslCommandToken, PluginToken Blue
|
|
113
|
+
{ token: 'number', foreground: '191970' }, // LetVariablesToken MidnightBlue
|
|
114
|
+
{ token: 'annotation', foreground: '9400D3' }, // ClientDirectiveToken DarkViolet
|
|
115
115
|
{ token: 'invalid', background: 'cd3131' },
|
|
116
116
|
],
|
|
117
117
|
colors: {},
|
|
@@ -120,21 +120,21 @@ monaco.editor.defineTheme(themeNames.dark, {
|
|
|
120
120
|
base: 'vs-dark',
|
|
121
121
|
inherit: true,
|
|
122
122
|
rules: [
|
|
123
|
-
{ token: 'comment', foreground: '608B4E' },
|
|
124
|
-
{ token: 'variable.predefined', foreground: '4ec9b0' },
|
|
125
|
-
{ token: 'function', foreground: 'dcdcaa' },
|
|
126
|
-
{ token: 'operator.sql', foreground: '9cdcfe' },
|
|
127
|
-
{ token: 'string', foreground: 'ce9178' },
|
|
128
|
-
{ token: 'operator.scss', foreground: '569cd6' },
|
|
129
|
-
{ token: 'variable', foreground: '4ec9b0' },
|
|
130
|
-
{ token: 'variable.parameter', foreground: 'c586c0' },
|
|
131
|
-
{ token: '', foreground: 'd4d4d4' },
|
|
132
|
-
{ token: 'type', foreground: '569cd6' },
|
|
133
|
-
{ token: 'tag', foreground: '569cd6' },
|
|
134
|
-
{ token: 'annotation', foreground: '9cdcfe' },
|
|
135
|
-
{ token: 'keyword', foreground: '569cd6' },
|
|
136
|
-
{ token: 'number', foreground: 'd7ba7d' },
|
|
137
|
-
{ token: 'annotation', foreground: 'b5cea8' },
|
|
123
|
+
{ token: 'comment', foreground: '608B4E' }, // CommentToken Green
|
|
124
|
+
{ token: 'variable.predefined', foreground: '4ec9b0' }, // CalculatedColumnToken Purple
|
|
125
|
+
{ token: 'function', foreground: 'dcdcaa' }, // FunctionNameToken Blue
|
|
126
|
+
{ token: 'operator.sql', foreground: '9cdcfe' }, // OperatorToken OrangeRed
|
|
127
|
+
{ token: 'string', foreground: 'ce9178' }, // StringLiteralToken Firebrick
|
|
128
|
+
{ token: 'operator.scss', foreground: '569cd6' }, // SubOperatorToken Blue
|
|
129
|
+
{ token: 'variable', foreground: '4ec9b0' }, // TableColumnToken MediumVioletRed
|
|
130
|
+
{ token: 'variable.parameter', foreground: 'c586c0' }, // TableToken DarkOrchid
|
|
131
|
+
{ token: '', foreground: 'd4d4d4' }, // UnknownToken, PlainTextToken Black
|
|
132
|
+
{ token: 'type', foreground: '569cd6' }, // DataTypeToken Blue
|
|
133
|
+
{ token: 'tag', foreground: '569cd6' }, // ControlCommandToken Blue
|
|
134
|
+
{ token: 'annotation', foreground: '9cdcfe' }, // QueryParametersToken FF2B91AF
|
|
135
|
+
{ token: 'keyword', foreground: '569cd6' }, // CslCommandToken, PluginToken Blue
|
|
136
|
+
{ token: 'number', foreground: 'd7ba7d' }, // LetVariablesToken MidnightBlue
|
|
137
|
+
{ token: 'annotation', foreground: 'b5cea8' }, // ClientDirectiveToken DarkViolet
|
|
138
138
|
{ token: 'invalid', background: 'cd3131' },
|
|
139
139
|
],
|
|
140
140
|
colors: {
|
|
@@ -147,7 +147,7 @@ monaco.editor.defineTheme(themeNames.dark2, {
|
|
|
147
147
|
rules: [],
|
|
148
148
|
colors: {
|
|
149
149
|
// see: https://code.visualstudio.com/api/references/theme-color#editor-widget-colors
|
|
150
|
-
'editor.background': '#1B1A19',
|
|
150
|
+
'editor.background': '#1B1A19', // gray 200
|
|
151
151
|
'editorSuggestWidget.selectedBackground': '#004E8C',
|
|
152
152
|
},
|
|
153
153
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!-----------------------------------------------------------------------------
|
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* monaco-kusto version: 11.
|
|
3
|
+
* monaco-kusto version: 11.1.0(a4f4a803b61d72aca89d2412b0c7849259e4fd91)
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://https://github.com/Azure/monaco-kusto/blob/master/README.md
|
|
6
6
|
*-----------------------------------------------------------------------------*/
|