@kusto/monaco-kusto 10.0.22 → 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 +17 -3
- package/package.json +11 -6
- package/release/dev/Kusto.Language.Bridge.min.js +110 -110
- package/release/dev/kustoMode.js +106 -76
- package/release/dev/kustoWorker.js +205 -342
- package/release/dev/{main-2c182d5b.js → main-326a932b.js} +8 -9
- package/release/dev/monaco.contribution.js +22 -25
- package/release/dev/{schema-c6f82d74.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 +46 -164
- 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 +4 -0
- package/release/esm/languageServiceManager/competionItemSort.js +25 -0
- package/release/esm/languageServiceManager/kustoLanguageService.d.ts +2 -2
- package/release/esm/languageServiceManager/kustoLanguageService.js +24 -173
- package/release/esm/languageServiceManager/kustoMonarchLanguageDefinition.js +1 -1
- package/release/esm/languageServiceManager/settings.d.ts +0 -1
- package/release/esm/monaco.contribution.js +31 -32
- package/release/esm/{schema-f88560be.js → schema-33d2a0bc.js} +1 -1
- package/release/min/Kusto.Language.Bridge.min.js +110 -110
- 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-acce8a2f.js → schema-9f26f1e2.js} +2 -2
- package/release/min/main-0657dac0.js +0 -7
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!-----------------------------------------------------------------------------
|
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* monaco-kusto version:
|
|
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/main-
|
|
8
|
+
define('vs/language/kusto/main-326a932b', ['exports'], (function (exports) { 'use strict';
|
|
9
9
|
|
|
10
10
|
/* --------------------------------------------------------------------------------------------
|
|
11
11
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -13,11 +13,11 @@ define('vs/language/kusto/main-2c182d5b', ['exports'], (function (exports) { 'us
|
|
|
13
13
|
* ------------------------------------------------------------------------------------------ */
|
|
14
14
|
|
|
15
15
|
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); }
|
|
16
|
-
function _classCallCheck(
|
|
17
|
-
function _defineProperties(
|
|
18
|
-
function _createClass(
|
|
19
|
-
function _toPropertyKey(
|
|
20
|
-
function _toPrimitive(
|
|
16
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
17
|
+
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); } }
|
|
18
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
19
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
20
|
+
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); }
|
|
21
21
|
var DocumentUri;
|
|
22
22
|
(function (DocumentUri) {
|
|
23
23
|
function is(value) {
|
|
@@ -1902,7 +1902,7 @@ define('vs/language/kusto/main-2c182d5b', ['exports'], (function (exports) { 'us
|
|
|
1902
1902
|
this._content = content;
|
|
1903
1903
|
this._lineOffsets = undefined;
|
|
1904
1904
|
}
|
|
1905
|
-
_createClass(FullTextDocument, [{
|
|
1905
|
+
return _createClass(FullTextDocument, [{
|
|
1906
1906
|
key: "uri",
|
|
1907
1907
|
get: function get() {
|
|
1908
1908
|
return this._uri;
|
|
@@ -2001,7 +2001,6 @@ define('vs/language/kusto/main-2c182d5b', ['exports'], (function (exports) { 'us
|
|
|
2001
2001
|
return this.getLineOffsets().length;
|
|
2002
2002
|
}
|
|
2003
2003
|
}]);
|
|
2004
|
-
return FullTextDocument;
|
|
2005
2004
|
}();
|
|
2006
2005
|
var Is;
|
|
2007
2006
|
(function (Is) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!-----------------------------------------------------------------------------
|
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* monaco-kusto version:
|
|
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,13 +234,11 @@ 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,
|
|
242
240
|
newlineAfterPipe: true,
|
|
243
241
|
openSuggestionDialogAfterPreviousSuggestionAccepted: true,
|
|
244
|
-
useIntellisenseV2: true,
|
|
245
242
|
useSemanticColorization: true,
|
|
246
243
|
useTokenColorization: false,
|
|
247
244
|
enableHover: true,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!-----------------------------------------------------------------------------
|
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* monaco-kusto version:
|
|
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:
|
|
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,12 +8,37 @@
|
|
|
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;
|
|
18
|
+
const createSortingText = priority => {
|
|
19
|
+
return priority.toString().padStart(10, '0');
|
|
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
|
+
}
|
|
41
|
+
|
|
17
42
|
var k = Kusto.Data.IntelliSense;
|
|
18
43
|
var parsing = Kusto.Language.Parsing;
|
|
19
44
|
var k2 = Kusto.Language.Editor;
|
|
@@ -213,7 +238,7 @@ class KustoLanguageService {
|
|
|
213
238
|
this.createRulesProvider(this._kustoJsSchema, this._schema.clusterType);
|
|
214
239
|
}
|
|
215
240
|
doComplete(document, position) {
|
|
216
|
-
return this.
|
|
241
|
+
return this.doCompleteV2(document, position);
|
|
217
242
|
}
|
|
218
243
|
disabledCompletionItemsV2 = {
|
|
219
244
|
// render charts
|
|
@@ -280,7 +305,8 @@ class KustoLanguageService {
|
|
|
280
305
|
});
|
|
281
306
|
}
|
|
282
307
|
const itemsAsArray = this.toArray(completionItems.Items);
|
|
283
|
-
|
|
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) => {
|
|
284
310
|
const v1CompletionOption = new k.CompletionOption(this._toOptionKind[kItem.Kind] || k.OptionKind.None, kItem.DisplayText);
|
|
285
311
|
const helpTopic = this.getTopic(v1CompletionOption);
|
|
286
312
|
// If we have AfterText it means that the cursor should not be placed at end of suggested text.
|
|
@@ -299,31 +325,26 @@ class KustoLanguageService {
|
|
|
299
325
|
format: ls.InsertTextFormat.PlainText
|
|
300
326
|
};
|
|
301
327
|
const lsItem = ls.CompletionItem.create(kItem.DisplayText);
|
|
302
|
-
|
|
303
|
-
// Adding to columns a prefix to their sortText so they will appear first in the list
|
|
304
|
-
let sortTextPrefix = lsItem.kind === ls.CompletionItemKind.Field ? 0 : itemsAsArray.length;
|
|
305
|
-
const countOfWords = lsItem.label.split('_').filter(item => !!item).length;
|
|
306
|
-
// We always want results with multiple words to show after shorter options.
|
|
307
|
-
// For example: to show "count_distinct" after "count"
|
|
308
|
-
sortTextPrefix = sortTextPrefix * countOfWords;
|
|
309
328
|
const startPosition = document.positionAt(completionItems.EditStart);
|
|
310
329
|
const endPosition = document.positionAt(completionItems.EditStart + completionItems.EditLength);
|
|
311
330
|
lsItem.textEdit = ls.TextEdit.replace(ls.Range.create(startPosition, endPosition), textToInsert);
|
|
312
|
-
lsItem.sortText = this.getSortText(sortTextPrefix + i + 1);
|
|
313
331
|
// Changing the first letter to be lower case, to ignore case-sensitive matching
|
|
314
332
|
lsItem.filterText = kItem.MatchText.charAt(0).toLowerCase() + kItem.MatchText.slice(1);
|
|
315
333
|
lsItem.kind = this.kustoKindToLsKindV2(kItem.Kind);
|
|
334
|
+
lsItem.sortText = createSortingText(index);
|
|
316
335
|
lsItem.insertTextFormat = format;
|
|
317
336
|
lsItem.detail = helpTopic ? helpTopic.ShortDescription : undefined;
|
|
318
337
|
lsItem.documentation = helpTopic ? {
|
|
319
338
|
value: this.formatHelpTopic(helpTopic),
|
|
320
339
|
kind: ls.MarkupKind.Markdown
|
|
321
340
|
} : undefined;
|
|
341
|
+
lsItem.data = {
|
|
342
|
+
forcePrecedence: kItem.Kind === k2.CompletionKind.Column
|
|
343
|
+
};
|
|
322
344
|
return lsItem;
|
|
323
345
|
});
|
|
324
346
|
return Promise.resolve(ls.CompletionList.create(items));
|
|
325
347
|
}
|
|
326
|
-
isIntellisenseV2 = () => this._languageSettings.useIntellisenseV2 && this._schema && this._schema.clusterType === 'Engine';
|
|
327
348
|
|
|
328
349
|
/**
|
|
329
350
|
* when trying to get a topic we need the function name (abs, toLower, ETC).
|
|
@@ -358,58 +379,6 @@ class KustoLanguageService {
|
|
|
358
379
|
attach: k.OptionKind.Command,
|
|
359
380
|
purge: k.OptionKind.Command
|
|
360
381
|
};
|
|
361
|
-
doCompleteV1(document, position) {
|
|
362
|
-
// TODO: fix typing in CslCommandParser to allow rulesProvider to be query only.
|
|
363
|
-
let caretAbsolutePosition = document.offsetAt(position);
|
|
364
|
-
|
|
365
|
-
// find out what's the current command to only parse this one.
|
|
366
|
-
this.parseDocumentV1(document, k.ParseMode.CommandTokensOnly);
|
|
367
|
-
let currentCommand = this.getCurrentCommand(document, caretAbsolutePosition);
|
|
368
|
-
let commandTextUntilCursor = '';
|
|
369
|
-
if (currentCommand) {
|
|
370
|
-
currentCommand.AbsoluteStart;
|
|
371
|
-
this.parseTextV1(currentCommand.Text, k.ParseMode.TokenizeAllText);
|
|
372
|
-
const caretRelativePosition = caretAbsolutePosition - currentCommand.AbsoluteStart;
|
|
373
|
-
commandTextUntilCursor = currentCommand.Text.substring(currentCommand.CslExpressionStartPosition, caretRelativePosition);
|
|
374
|
-
}
|
|
375
|
-
let commandTextWithoutLastWord = this.getCommandWithoutLastWord(commandTextUntilCursor);
|
|
376
|
-
let context = this._rulesProvider.AnalyzeCommand$1(commandTextUntilCursor, currentCommand).Context;
|
|
377
|
-
let result = {
|
|
378
|
-
v: null
|
|
379
|
-
};
|
|
380
|
-
this._rulesProvider.TryMatchAnyRule(commandTextWithoutLastWord, result);
|
|
381
|
-
let rule = result.v;
|
|
382
|
-
if (rule) {
|
|
383
|
-
const completionOptions = this.toArray(rule.GetCompletionOptions(context));
|
|
384
|
-
|
|
385
|
-
// TODO once AppendPipePolicy becomes a public static member of ApplyPolicy in our c# code, and bridge.Net transplies this,
|
|
386
|
-
// remove the 'as any' part..
|
|
387
|
-
// Also = DefaultApplyPolicy is internal in c# code, so not exposed in d.ts, so we cast it to any.
|
|
388
|
-
if (this._languageSettings.newlineAfterPipe && rule.DefaultAfterApplyPolicy === Kusto.Data.IntelliSense.ApplyPolicy.AppendPipePolicy) {
|
|
389
|
-
rule.DefaultAfterApplyPolicy = this._newlineAppendPipePolicy;
|
|
390
|
-
}
|
|
391
|
-
let options = completionOptions.filter(option => !(option && option.Value && this.disabledCompletionItemsV1[option.Value] === option.Kind)).map((option, ordinal) => {
|
|
392
|
-
const {
|
|
393
|
-
insertText,
|
|
394
|
-
insertTextFormat
|
|
395
|
-
} = this.getTextToInsert(rule, option);
|
|
396
|
-
const helpTopic = k.CslDocumentation.Instance.GetTopic(option);
|
|
397
|
-
const item = ls.CompletionItem.create(option.Value);
|
|
398
|
-
item.kind = this.kustoKindToLsKind(option.Kind);
|
|
399
|
-
item.insertText = insertText;
|
|
400
|
-
item.insertTextFormat = insertTextFormat;
|
|
401
|
-
item.sortText = this.getSortText(ordinal + 1);
|
|
402
|
-
item.detail = helpTopic ? helpTopic.ShortDescription : undefined;
|
|
403
|
-
item.documentation = helpTopic ? {
|
|
404
|
-
value: helpTopic.LongDescription,
|
|
405
|
-
kind: ls.MarkupKind.Markdown
|
|
406
|
-
} : undefined;
|
|
407
|
-
return item;
|
|
408
|
-
});
|
|
409
|
-
return Promise.resolve(ls.CompletionList.create(options));
|
|
410
|
-
}
|
|
411
|
-
return Promise.resolve(ls.CompletionList.create([]));
|
|
412
|
-
}
|
|
413
382
|
doRangeFormat(document, range) {
|
|
414
383
|
if (!document) {
|
|
415
384
|
return Promise.resolve([]);
|
|
@@ -525,7 +494,7 @@ class KustoLanguageService {
|
|
|
525
494
|
}
|
|
526
495
|
doValidation(document, changeIntervals, includeWarnings, includeSuggestions) {
|
|
527
496
|
// didn't implement validation for v1.
|
|
528
|
-
if (!document
|
|
497
|
+
if (!document) {
|
|
529
498
|
return Promise.resolve([]);
|
|
530
499
|
}
|
|
531
500
|
const script = this.parseDocumentV2(document);
|
|
@@ -661,56 +630,6 @@ class KustoLanguageService {
|
|
|
661
630
|
return Promise.resolve([]);
|
|
662
631
|
}
|
|
663
632
|
|
|
664
|
-
// V1 intellisense
|
|
665
|
-
if (!this.isIntellisenseV2()) {
|
|
666
|
-
// Handle specific ranges changes (and not the whole doc)
|
|
667
|
-
if (changeIntervals.length > 0) {
|
|
668
|
-
this.parseDocumentV1(document, k.ParseMode.CommandTokensOnly);
|
|
669
|
-
const affectedCommands = this.toArray(this._parser.Results).filter(command =>
|
|
670
|
-
// a command is affected if it intersects at least on of changed ranges.
|
|
671
|
-
command // command can be null. we're filtering all nulls in the array.
|
|
672
|
-
? changeIntervals.some(({
|
|
673
|
-
start: changeStart,
|
|
674
|
-
end: changeEnd
|
|
675
|
-
}) =>
|
|
676
|
-
// both intervals intersect if either the start or the end of interval A is inside interval B.
|
|
677
|
-
// If we deleted something at the end of a command, the interval will not intersect the current command.
|
|
678
|
-
// so we also want consider affected commands commands the end where the interval begins.
|
|
679
|
-
// hence the + 1.
|
|
680
|
-
command.AbsoluteStart >= changeStart && command.AbsoluteStart <= changeEnd || changeStart >= command.AbsoluteStart && changeStart <= command.AbsoluteEnd + 1) : false);
|
|
681
|
-
|
|
682
|
-
// We're not on any command so don't return any classifications.
|
|
683
|
-
// this can happen if we're at the and of the file and deleting empty rows (for example).
|
|
684
|
-
if (!affectedCommands || affectedCommands.length === 0) {
|
|
685
|
-
return Promise.resolve([{
|
|
686
|
-
classifications: [],
|
|
687
|
-
absoluteStart: changeIntervals[0].start,
|
|
688
|
-
absoluteEnd: changeIntervals[0].end
|
|
689
|
-
}]);
|
|
690
|
-
}
|
|
691
|
-
const results = affectedCommands.map(command => {
|
|
692
|
-
this.parseTextV1(command.Text, k.ParseMode.TokenizeAllText);
|
|
693
|
-
const k2Classifications = this.getClassificationsFromParseResult(command.AbsoluteStart);
|
|
694
|
-
const classifications = toClassifiedRange(k2Classifications);
|
|
695
|
-
return {
|
|
696
|
-
classifications: classifications,
|
|
697
|
-
absoluteStart: command.AbsoluteStart,
|
|
698
|
-
absoluteEnd: command.AbsoluteEnd
|
|
699
|
-
};
|
|
700
|
-
});
|
|
701
|
-
return Promise.resolve(results);
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
// Entire document requested
|
|
705
|
-
this.parseDocumentV1(document, k.ParseMode.TokenizeAllText);
|
|
706
|
-
const classifications = this.getClassificationsFromParseResult();
|
|
707
|
-
return Promise.resolve([{
|
|
708
|
-
classifications: toClassifiedRange(classifications),
|
|
709
|
-
absoluteStart: 0,
|
|
710
|
-
absoluteEnd: document.getText().length
|
|
711
|
-
}]);
|
|
712
|
-
}
|
|
713
|
-
|
|
714
633
|
// V2 intellisense
|
|
715
634
|
const script = this.parseDocumentV2(document);
|
|
716
635
|
if (changeIntervals.length > 0) {
|
|
@@ -790,7 +709,7 @@ class KustoLanguageService {
|
|
|
790
709
|
setSchema(schema) {
|
|
791
710
|
this._schema = schema;
|
|
792
711
|
// We support intellisenseV2 only if the clusterType is "Engine", even if the setting is enabled
|
|
793
|
-
if (
|
|
712
|
+
if (schema && schema.clusterType === 'Engine') {
|
|
794
713
|
let kustoJsSchemaV2 = this.convertToKustoJsSchemaV2(schema);
|
|
795
714
|
this._kustoJsSchemaV2 = kustoJsSchemaV2;
|
|
796
715
|
this._script = undefined;
|
|
@@ -805,7 +724,7 @@ class KustoLanguageService {
|
|
|
805
724
|
return Promise.resolve();
|
|
806
725
|
}
|
|
807
726
|
setParameters(scalarParameters, tabularParameters) {
|
|
808
|
-
if (
|
|
727
|
+
if (this._schema.clusterType !== 'Engine') {
|
|
809
728
|
throw new Error('setParameters requires intellisense V2 and Engine cluster');
|
|
810
729
|
}
|
|
811
730
|
this._schema.globalScalarParameters = scalarParameters;
|
|
@@ -934,11 +853,11 @@ class KustoLanguageService {
|
|
|
934
853
|
return Promise.resolve(this._schema);
|
|
935
854
|
}
|
|
936
855
|
getCommandInContext(document, cursorOffset) {
|
|
937
|
-
return this.
|
|
856
|
+
return this.getCommandInContextV2(document, cursorOffset);
|
|
938
857
|
}
|
|
939
858
|
getCommandAndLocationInContext(document, cursorOffset) {
|
|
940
859
|
// We are going to remove v1 intellisense. no use to keep parity.
|
|
941
|
-
if (!document
|
|
860
|
+
if (!document) {
|
|
942
861
|
return Promise.resolve(null);
|
|
943
862
|
}
|
|
944
863
|
const script = this.parseDocumentV2(document);
|
|
@@ -955,14 +874,6 @@ class KustoLanguageService {
|
|
|
955
874
|
location
|
|
956
875
|
});
|
|
957
876
|
}
|
|
958
|
-
getCommandInContextV1(document, cursorOffset) {
|
|
959
|
-
this.parseDocumentV1(document, k.ParseMode.CommandTokensOnly);
|
|
960
|
-
const command = this.getCurrentCommand(document, cursorOffset);
|
|
961
|
-
if (!command) {
|
|
962
|
-
return Promise.resolve(null);
|
|
963
|
-
}
|
|
964
|
-
return Promise.resolve(command.Text);
|
|
965
|
-
}
|
|
966
877
|
getCommandInContextV2(document, cursorOffset) {
|
|
967
878
|
if (!document) {
|
|
968
879
|
return Promise.resolve(null);
|
|
@@ -984,7 +895,7 @@ class KustoLanguageService {
|
|
|
984
895
|
if (!document) {
|
|
985
896
|
return Promise.resolve([]);
|
|
986
897
|
}
|
|
987
|
-
return this.
|
|
898
|
+
return this.getCommandsInDocumentV2(document);
|
|
988
899
|
}
|
|
989
900
|
getCommandsInDocumentV1(document) {
|
|
990
901
|
this.parseDocumentV1(document, k.ParseMode.CommandTokensOnly);
|
|
@@ -1088,7 +999,7 @@ class KustoLanguageService {
|
|
|
1088
999
|
});
|
|
1089
1000
|
}
|
|
1090
1001
|
findDefinition(document, position) {
|
|
1091
|
-
if (!document
|
|
1002
|
+
if (!document) {
|
|
1092
1003
|
return Promise.resolve([]);
|
|
1093
1004
|
}
|
|
1094
1005
|
const script = this.parseDocumentV2(document);
|
|
@@ -1110,7 +1021,7 @@ class KustoLanguageService {
|
|
|
1110
1021
|
return Promise.resolve([location]);
|
|
1111
1022
|
}
|
|
1112
1023
|
findReferences(document, position) {
|
|
1113
|
-
if (!document
|
|
1024
|
+
if (!document) {
|
|
1114
1025
|
return Promise.resolve([]);
|
|
1115
1026
|
}
|
|
1116
1027
|
const script = this.parseDocumentV2(document);
|
|
@@ -1134,10 +1045,9 @@ class KustoLanguageService {
|
|
|
1134
1045
|
return Promise.resolve(references);
|
|
1135
1046
|
}
|
|
1136
1047
|
getQueryParams(document, cursorOffset) {
|
|
1137
|
-
if (!document
|
|
1048
|
+
if (!document) {
|
|
1138
1049
|
return Promise.resolve([]);
|
|
1139
1050
|
}
|
|
1140
|
-
this.parseDocumentV2(document);
|
|
1141
1051
|
const parsedAndAnalyzed = this.parseAndAnalyze(document, cursorOffset);
|
|
1142
1052
|
const queryParamStatements = this.toArray(parsedAndAnalyzed.Syntax.GetDescendants(Kusto.Language.Syntax.QueryParametersStatement));
|
|
1143
1053
|
if (!queryParamStatements || queryParamStatements.length == 0) {
|
|
@@ -1285,9 +1195,6 @@ class KustoLanguageService {
|
|
|
1285
1195
|
return Promise.resolve(result);
|
|
1286
1196
|
}
|
|
1287
1197
|
getGlobalParams(document) {
|
|
1288
|
-
if (!this.isIntellisenseV2()) {
|
|
1289
|
-
return Promise.resolve([]);
|
|
1290
|
-
}
|
|
1291
1198
|
const params = this.toArray(this._kustoJsSchemaV2.Parameters);
|
|
1292
1199
|
const result = params.map(param => ({
|
|
1293
1200
|
name: param.Name,
|
|
@@ -1296,7 +1203,7 @@ class KustoLanguageService {
|
|
|
1296
1203
|
return Promise.resolve(result);
|
|
1297
1204
|
}
|
|
1298
1205
|
doRename(document, position, newName) {
|
|
1299
|
-
if (!document
|
|
1206
|
+
if (!document) {
|
|
1300
1207
|
return Promise.resolve(undefined);
|
|
1301
1208
|
}
|
|
1302
1209
|
const script = this.parseDocumentV2(document);
|
|
@@ -1329,7 +1236,7 @@ class KustoLanguageService {
|
|
|
1329
1236
|
return Promise.resolve(workspaceEdit);
|
|
1330
1237
|
}
|
|
1331
1238
|
doHover(document, position) {
|
|
1332
|
-
if (!document
|
|
1239
|
+
if (!document) {
|
|
1333
1240
|
return Promise.resolve(undefined);
|
|
1334
1241
|
}
|
|
1335
1242
|
const script = this.parseDocumentV2(document);
|
|
@@ -1597,30 +1504,6 @@ class KustoLanguageService {
|
|
|
1597
1504
|
return newRange;
|
|
1598
1505
|
}
|
|
1599
1506
|
|
|
1600
|
-
/**
|
|
1601
|
-
* Maps numbers to strings, such that if a>b numerically, f(a)>f(b) lexicographically.
|
|
1602
|
-
* 1 -> "a", 26 -> "z", 27 -> "za", 28 -> "zb", 52 -> "zz", 53 ->"zza"
|
|
1603
|
-
* @param order - The number to be converted to a sorting-string. order should start at 1.
|
|
1604
|
-
* @returns A string repenting the order.
|
|
1605
|
-
*/
|
|
1606
|
-
getSortText(order) {
|
|
1607
|
-
if (order <= 0) {
|
|
1608
|
-
throw new RangeError(`order should be a number >= 1. instead got ${order}`);
|
|
1609
|
-
}
|
|
1610
|
-
let sortText = '';
|
|
1611
|
-
let numCharacters = 26; // "z" - "a" + 1;
|
|
1612
|
-
|
|
1613
|
-
let div = Math.floor(order / numCharacters);
|
|
1614
|
-
for (let i = 0; i < div; ++i) {
|
|
1615
|
-
sortText += 'z';
|
|
1616
|
-
}
|
|
1617
|
-
let reminder = order % numCharacters;
|
|
1618
|
-
if (reminder > 0) {
|
|
1619
|
-
sortText += String.fromCharCode(96 + reminder);
|
|
1620
|
-
}
|
|
1621
|
-
return sortText;
|
|
1622
|
-
}
|
|
1623
|
-
|
|
1624
1507
|
/**
|
|
1625
1508
|
* ParseTextV1 parses the given text with the given parse mode.
|
|
1626
1509
|
* Additionally - it will make sure not to provide rules provider for non-engine clusters
|
|
@@ -1855,7 +1738,7 @@ class KustoLanguageService {
|
|
|
1855
1738
|
return conversion || k2.ClassificationKind.PlainText;
|
|
1856
1739
|
}
|
|
1857
1740
|
parseAndAnalyze(document, cursorOffset) {
|
|
1858
|
-
if (!document
|
|
1741
|
+
if (!document) {
|
|
1859
1742
|
return undefined;
|
|
1860
1743
|
}
|
|
1861
1744
|
const script = this.parseDocumentV2(document);
|
|
@@ -1900,7 +1783,6 @@ class KustoLanguageService {
|
|
|
1900
1783
|
}
|
|
1901
1784
|
let languageService = new KustoLanguageService(KustoLanguageService.dummySchema, {
|
|
1902
1785
|
includeControlCommands: true,
|
|
1903
|
-
useIntellisenseV2: true,
|
|
1904
1786
|
useSemanticColorization: true,
|
|
1905
1787
|
completionOptions: {
|
|
1906
1788
|
includeExtendedSyntax: false
|
|
@@ -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;
|