@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
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="@kusto/language-service-next/Kusto.Language.Bridge" />
|
|
2
|
+
import k2 = Kusto.Language.Editor;
|
|
3
|
+
export declare const createSortingText: (priority: number) => string;
|
|
4
|
+
export declare function sortByMatchTextKeepingKindOrder(items: k2.CompletionItem[]): k2.CompletionItem[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export var createSortingText = function (priority) {
|
|
2
|
+
return priority.toString().padStart(10, '0');
|
|
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,6 +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, sortByMatchTextKeepingKindOrder } from './competionItemSort';
|
|
44
45
|
var List = System.Collections.Generic.List$1;
|
|
45
46
|
function assertNever(x) {
|
|
46
47
|
throw new Error('Unexpected object: ' + x);
|
|
@@ -139,7 +140,6 @@ var symbolKindToName = (_a = {},
|
|
|
139
140
|
var KustoLanguageService = /** @class */ (function () {
|
|
140
141
|
function KustoLanguageService(schema, languageSettings) {
|
|
141
142
|
var _a, _b, _c, _d;
|
|
142
|
-
var _this = this;
|
|
143
143
|
/**
|
|
144
144
|
* Taken from:
|
|
145
145
|
* https://msazure.visualstudio.com/One/_git/Azure-Kusto-Service?path=/Src/Tools/Kusto.Explorer.Control/QueryEditors/KustoScriptEditor/KustoScriptEditorControl2.xaml.cs&version=GBdev&line=2075&lineEnd=2075&lineStartColumn=9&lineEndColumn=77&lineStyle=plain&_a=contents
|
|
@@ -183,9 +183,6 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
183
183
|
'3Dchart': k2.CompletionKind.RenderChart,
|
|
184
184
|
list: k2.CompletionKind.RenderChart,
|
|
185
185
|
};
|
|
186
|
-
this.isIntellisenseV2 = function () {
|
|
187
|
-
return _this._languageSettings.useIntellisenseV2 && _this._schema && _this._schema.clusterType === 'Engine';
|
|
188
|
-
};
|
|
189
186
|
this.disabledCompletionItemsV1 = {
|
|
190
187
|
capacity: k.OptionKind.Policy,
|
|
191
188
|
callout: k.OptionKind.Policy,
|
|
@@ -272,13 +269,13 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
272
269
|
_d[TokenKind.CommentToken] = k2.ClassificationKind.Comment,
|
|
273
270
|
_d[TokenKind.PlainTextToken] = k2.ClassificationKind.PlainText,
|
|
274
271
|
_d[TokenKind.DataTypeToken] = k2.ClassificationKind.Type,
|
|
275
|
-
_d[TokenKind.ControlCommandToken] = k2.ClassificationKind.PlainText,
|
|
276
|
-
_d[TokenKind.CommandPartToken] = k2.ClassificationKind.PlainText,
|
|
272
|
+
_d[TokenKind.ControlCommandToken] = k2.ClassificationKind.PlainText, // TODO ?
|
|
273
|
+
_d[TokenKind.CommandPartToken] = k2.ClassificationKind.PlainText, // TODO ?
|
|
277
274
|
_d[TokenKind.QueryParametersToken] = k2.ClassificationKind.QueryParameter,
|
|
278
|
-
_d[TokenKind.CslCommandToken] = k2.ClassificationKind.Keyword,
|
|
279
|
-
_d[TokenKind.LetVariablesToken] = k2.ClassificationKind.Identifier,
|
|
275
|
+
_d[TokenKind.CslCommandToken] = k2.ClassificationKind.Keyword, // TODO ?
|
|
276
|
+
_d[TokenKind.LetVariablesToken] = k2.ClassificationKind.Identifier, // TODO ?
|
|
280
277
|
_d[TokenKind.PluginToken] = k2.ClassificationKind.Function,
|
|
281
|
-
_d[TokenKind.BracketRangeToken] = k2.ClassificationKind.Keyword,
|
|
278
|
+
_d[TokenKind.BracketRangeToken] = k2.ClassificationKind.Keyword, // TODO ?
|
|
282
279
|
_d[TokenKind.ClientDirectiveToken] = k2.ClassificationKind.Keyword,
|
|
283
280
|
_d);
|
|
284
281
|
this._schemaCache = {};
|
|
@@ -334,7 +331,7 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
334
331
|
this.createRulesProvider(this._kustoJsSchema, this._schema.clusterType);
|
|
335
332
|
};
|
|
336
333
|
KustoLanguageService.prototype.doComplete = function (document, position) {
|
|
337
|
-
return this.
|
|
334
|
+
return this.doCompleteV2(document, position);
|
|
338
335
|
};
|
|
339
336
|
/**
|
|
340
337
|
* important: Only use during development to test Global State.
|
|
@@ -387,7 +384,8 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
387
384
|
});
|
|
388
385
|
}
|
|
389
386
|
var itemsAsArray = this.toArray(completionItems.Items);
|
|
390
|
-
var
|
|
387
|
+
var sortedArray = sortByMatchTextKeepingKindOrder(itemsAsArray);
|
|
388
|
+
var items = sortedArray
|
|
391
389
|
.filter(function (item) {
|
|
392
390
|
return !(item &&
|
|
393
391
|
item.MatchText &&
|
|
@@ -395,7 +393,7 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
395
393
|
(disabledItems[item.MatchText] === k2.CompletionKind.Unknown ||
|
|
396
394
|
disabledItems[item.MatchText] === item.Kind));
|
|
397
395
|
})
|
|
398
|
-
.map(function (kItem,
|
|
396
|
+
.map(function (kItem, index) {
|
|
399
397
|
var v1CompletionOption = new k.CompletionOption(_this._toOptionKind[kItem.Kind] || k.OptionKind.None, kItem.DisplayText);
|
|
400
398
|
var helpTopic = _this.getTopic(v1CompletionOption);
|
|
401
399
|
// If we have AfterText it means that the cursor should not be placed at end of suggested text.
|
|
@@ -413,24 +411,19 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
413
411
|
format: ls.InsertTextFormat.PlainText,
|
|
414
412
|
}, textToInsert = _a.textToInsert, format = _a.format;
|
|
415
413
|
var lsItem = ls.CompletionItem.create(kItem.DisplayText);
|
|
416
|
-
// Adding to columns a prefix to their sortText so they will appear first in the list
|
|
417
|
-
var sortTextPrefix = lsItem.kind === ls.CompletionItemKind.Field ? 0 : itemsAsArray.length;
|
|
418
|
-
var countOfWords = lsItem.label.split('_').filter(function (item) { return !!item; }).length;
|
|
419
|
-
// We always want results with multiple words to show after shorter options.
|
|
420
|
-
// For example: to show "count_distinct" after "count"
|
|
421
|
-
sortTextPrefix = sortTextPrefix * countOfWords;
|
|
422
414
|
var startPosition = document.positionAt(completionItems.EditStart);
|
|
423
415
|
var endPosition = document.positionAt(completionItems.EditStart + completionItems.EditLength);
|
|
424
416
|
lsItem.textEdit = ls.TextEdit.replace(ls.Range.create(startPosition, endPosition), textToInsert);
|
|
425
|
-
lsItem.sortText = _this.getSortText(sortTextPrefix + i + 1);
|
|
426
417
|
// Changing the first letter to be lower case, to ignore case-sensitive matching
|
|
427
418
|
lsItem.filterText = kItem.MatchText.charAt(0).toLowerCase() + kItem.MatchText.slice(1);
|
|
428
419
|
lsItem.kind = _this.kustoKindToLsKindV2(kItem.Kind);
|
|
420
|
+
lsItem.sortText = createSortingText(index);
|
|
429
421
|
lsItem.insertTextFormat = format;
|
|
430
422
|
lsItem.detail = helpTopic ? helpTopic.ShortDescription : undefined;
|
|
431
423
|
lsItem.documentation = helpTopic
|
|
432
424
|
? { value: _this.formatHelpTopic(helpTopic), kind: ls.MarkupKind.Markdown }
|
|
433
425
|
: undefined;
|
|
426
|
+
lsItem.data = { forcePrecedence: kItem.Kind === k2.CompletionKind.Column };
|
|
434
427
|
return lsItem;
|
|
435
428
|
});
|
|
436
429
|
return Promise.resolve(ls.CompletionList.create(items));
|
|
@@ -453,56 +446,6 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
453
446
|
}
|
|
454
447
|
return k.CslDocumentation.Instance.GetTopic(completionOption);
|
|
455
448
|
};
|
|
456
|
-
KustoLanguageService.prototype.doCompleteV1 = function (document, position) {
|
|
457
|
-
var _this = this;
|
|
458
|
-
// TODO: fix typing in CslCommandParser to allow rulesProvider to be query only.
|
|
459
|
-
var caretAbsolutePosition = document.offsetAt(position);
|
|
460
|
-
// find out what's the current command to only parse this one.
|
|
461
|
-
this.parseDocumentV1(document, k.ParseMode.CommandTokensOnly);
|
|
462
|
-
var currentCommand = this.getCurrentCommand(document, caretAbsolutePosition);
|
|
463
|
-
var commandTextUntilCursor = '';
|
|
464
|
-
if (currentCommand) {
|
|
465
|
-
var commandStartOffset = currentCommand.AbsoluteStart;
|
|
466
|
-
this.parseTextV1(currentCommand.Text, k.ParseMode.TokenizeAllText);
|
|
467
|
-
var caretRelativePosition = caretAbsolutePosition - currentCommand.AbsoluteStart;
|
|
468
|
-
commandTextUntilCursor = currentCommand.Text.substring(currentCommand.CslExpressionStartPosition, caretRelativePosition);
|
|
469
|
-
}
|
|
470
|
-
var commandTextWithoutLastWord = this.getCommandWithoutLastWord(commandTextUntilCursor);
|
|
471
|
-
var context = this._rulesProvider.AnalyzeCommand$1(commandTextUntilCursor, currentCommand).Context;
|
|
472
|
-
var result = { v: null };
|
|
473
|
-
this._rulesProvider.TryMatchAnyRule(commandTextWithoutLastWord, result);
|
|
474
|
-
var rule = result.v;
|
|
475
|
-
if (rule) {
|
|
476
|
-
var completionOptions = this.toArray(rule.GetCompletionOptions(context));
|
|
477
|
-
// TODO once AppendPipePolicy becomes a public static member of ApplyPolicy in our c# code, and bridge.Net transplies this,
|
|
478
|
-
// remove the 'as any' part..
|
|
479
|
-
// Also = DefaultApplyPolicy is internal in c# code, so not exposed in d.ts, so we cast it to any.
|
|
480
|
-
if (this._languageSettings.newlineAfterPipe &&
|
|
481
|
-
rule.DefaultAfterApplyPolicy === Kusto.Data.IntelliSense.ApplyPolicy.AppendPipePolicy) {
|
|
482
|
-
rule.DefaultAfterApplyPolicy = this._newlineAppendPipePolicy;
|
|
483
|
-
}
|
|
484
|
-
var options = completionOptions
|
|
485
|
-
.filter(function (option) {
|
|
486
|
-
return !(option && option.Value && _this.disabledCompletionItemsV1[option.Value] === option.Kind);
|
|
487
|
-
})
|
|
488
|
-
.map(function (option, ordinal) {
|
|
489
|
-
var _a = _this.getTextToInsert(rule, option), insertText = _a.insertText, insertTextFormat = _a.insertTextFormat;
|
|
490
|
-
var helpTopic = k.CslDocumentation.Instance.GetTopic(option);
|
|
491
|
-
var item = ls.CompletionItem.create(option.Value);
|
|
492
|
-
item.kind = _this.kustoKindToLsKind(option.Kind);
|
|
493
|
-
item.insertText = insertText;
|
|
494
|
-
item.insertTextFormat = insertTextFormat;
|
|
495
|
-
item.sortText = _this.getSortText(ordinal + 1);
|
|
496
|
-
item.detail = helpTopic ? helpTopic.ShortDescription : undefined;
|
|
497
|
-
item.documentation = helpTopic
|
|
498
|
-
? { value: helpTopic.LongDescription, kind: ls.MarkupKind.Markdown }
|
|
499
|
-
: undefined;
|
|
500
|
-
return item;
|
|
501
|
-
});
|
|
502
|
-
return Promise.resolve(ls.CompletionList.create(options));
|
|
503
|
-
}
|
|
504
|
-
return Promise.resolve(ls.CompletionList.create([]));
|
|
505
|
-
};
|
|
506
449
|
KustoLanguageService.prototype.doRangeFormat = function (document, range) {
|
|
507
450
|
if (!document) {
|
|
508
451
|
return Promise.resolve([]);
|
|
@@ -614,7 +557,7 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
614
557
|
KustoLanguageService.prototype.doValidation = function (document, changeIntervals, includeWarnings, includeSuggestions) {
|
|
615
558
|
var _this = this;
|
|
616
559
|
// didn't implement validation for v1.
|
|
617
|
-
if (!document
|
|
560
|
+
if (!document) {
|
|
618
561
|
return Promise.resolve([]);
|
|
619
562
|
}
|
|
620
563
|
var script = this.parseDocumentV2(document);
|
|
@@ -749,59 +692,6 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
749
692
|
if (!document || !this._languageSettings.useSemanticColorization) {
|
|
750
693
|
return Promise.resolve([]);
|
|
751
694
|
}
|
|
752
|
-
// V1 intellisense
|
|
753
|
-
if (!this.isIntellisenseV2()) {
|
|
754
|
-
// Handle specific ranges changes (and not the whole doc)
|
|
755
|
-
if (changeIntervals.length > 0) {
|
|
756
|
-
this.parseDocumentV1(document, k.ParseMode.CommandTokensOnly);
|
|
757
|
-
var affectedCommands = this.toArray(this._parser.Results).filter(function (command) {
|
|
758
|
-
// a command is affected if it intersects at least on of changed ranges.
|
|
759
|
-
return command // command can be null. we're filtering all nulls in the array.
|
|
760
|
-
? changeIntervals.some(function (_a) {
|
|
761
|
-
var changeStart = _a.start, changeEnd = _a.end;
|
|
762
|
-
// both intervals intersect if either the start or the end of interval A is inside interval B.
|
|
763
|
-
// If we deleted something at the end of a command, the interval will not intersect the current command.
|
|
764
|
-
// so we also want consider affected commands commands the end where the interval begins.
|
|
765
|
-
// hence the + 1.
|
|
766
|
-
return (command.AbsoluteStart >= changeStart && command.AbsoluteStart <= changeEnd) ||
|
|
767
|
-
(changeStart >= command.AbsoluteStart && changeStart <= command.AbsoluteEnd + 1);
|
|
768
|
-
})
|
|
769
|
-
: false;
|
|
770
|
-
});
|
|
771
|
-
// We're not on any command so don't return any classifications.
|
|
772
|
-
// this can happen if we're at the and of the file and deleting empty rows (for example).
|
|
773
|
-
if (!affectedCommands || affectedCommands.length === 0) {
|
|
774
|
-
return Promise.resolve([
|
|
775
|
-
{
|
|
776
|
-
classifications: [],
|
|
777
|
-
absoluteStart: changeIntervals[0].start,
|
|
778
|
-
absoluteEnd: changeIntervals[0].end,
|
|
779
|
-
},
|
|
780
|
-
]);
|
|
781
|
-
}
|
|
782
|
-
var results = affectedCommands.map(function (command) {
|
|
783
|
-
_this.parseTextV1(command.Text, k.ParseMode.TokenizeAllText);
|
|
784
|
-
var k2Classifications = _this.getClassificationsFromParseResult(command.AbsoluteStart);
|
|
785
|
-
var classifications = toClassifiedRange(k2Classifications);
|
|
786
|
-
return {
|
|
787
|
-
classifications: classifications,
|
|
788
|
-
absoluteStart: command.AbsoluteStart,
|
|
789
|
-
absoluteEnd: command.AbsoluteEnd,
|
|
790
|
-
};
|
|
791
|
-
});
|
|
792
|
-
return Promise.resolve(results);
|
|
793
|
-
}
|
|
794
|
-
// Entire document requested
|
|
795
|
-
this.parseDocumentV1(document, k.ParseMode.TokenizeAllText);
|
|
796
|
-
var classifications_1 = this.getClassificationsFromParseResult();
|
|
797
|
-
return Promise.resolve([
|
|
798
|
-
{
|
|
799
|
-
classifications: toClassifiedRange(classifications_1),
|
|
800
|
-
absoluteStart: 0,
|
|
801
|
-
absoluteEnd: document.getText().length,
|
|
802
|
-
},
|
|
803
|
-
]);
|
|
804
|
-
}
|
|
805
695
|
// V2 intellisense
|
|
806
696
|
var script = this.parseDocumentV2(document);
|
|
807
697
|
if (changeIntervals.length > 0) {
|
|
@@ -885,7 +775,7 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
885
775
|
KustoLanguageService.prototype.setSchema = function (schema) {
|
|
886
776
|
this._schema = schema;
|
|
887
777
|
// We support intellisenseV2 only if the clusterType is "Engine", even if the setting is enabled
|
|
888
|
-
if (
|
|
778
|
+
if (schema && schema.clusterType === 'Engine') {
|
|
889
779
|
var kustoJsSchemaV2 = this.convertToKustoJsSchemaV2(schema);
|
|
890
780
|
this._kustoJsSchemaV2 = kustoJsSchemaV2;
|
|
891
781
|
this._script = undefined;
|
|
@@ -899,7 +789,7 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
899
789
|
};
|
|
900
790
|
KustoLanguageService.prototype.setParameters = function (scalarParameters, tabularParameters) {
|
|
901
791
|
var _a;
|
|
902
|
-
if (
|
|
792
|
+
if (this._schema.clusterType !== 'Engine') {
|
|
903
793
|
throw new Error('setParameters requires intellisense V2 and Engine cluster');
|
|
904
794
|
}
|
|
905
795
|
this._schema.globalScalarParameters = scalarParameters;
|
|
@@ -1031,13 +921,11 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
1031
921
|
return Promise.resolve(this._schema);
|
|
1032
922
|
};
|
|
1033
923
|
KustoLanguageService.prototype.getCommandInContext = function (document, cursorOffset) {
|
|
1034
|
-
return this.
|
|
1035
|
-
? this.getCommandInContextV2(document, cursorOffset)
|
|
1036
|
-
: this.getCommandInContextV1(document, cursorOffset);
|
|
924
|
+
return this.getCommandInContextV2(document, cursorOffset);
|
|
1037
925
|
};
|
|
1038
926
|
KustoLanguageService.prototype.getCommandAndLocationInContext = function (document, cursorOffset) {
|
|
1039
927
|
// We are going to remove v1 intellisense. no use to keep parity.
|
|
1040
|
-
if (!document
|
|
928
|
+
if (!document) {
|
|
1041
929
|
return Promise.resolve(null);
|
|
1042
930
|
}
|
|
1043
931
|
var script = this.parseDocumentV2(document);
|
|
@@ -1054,14 +942,6 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
1054
942
|
location: location,
|
|
1055
943
|
});
|
|
1056
944
|
};
|
|
1057
|
-
KustoLanguageService.prototype.getCommandInContextV1 = function (document, cursorOffset) {
|
|
1058
|
-
this.parseDocumentV1(document, k.ParseMode.CommandTokensOnly);
|
|
1059
|
-
var command = this.getCurrentCommand(document, cursorOffset);
|
|
1060
|
-
if (!command) {
|
|
1061
|
-
return Promise.resolve(null);
|
|
1062
|
-
}
|
|
1063
|
-
return Promise.resolve(command.Text);
|
|
1064
|
-
};
|
|
1065
945
|
KustoLanguageService.prototype.getCommandInContextV2 = function (document, cursorOffset) {
|
|
1066
946
|
if (!document) {
|
|
1067
947
|
return Promise.resolve(null);
|
|
@@ -1081,9 +961,7 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
1081
961
|
if (!document) {
|
|
1082
962
|
return Promise.resolve([]);
|
|
1083
963
|
}
|
|
1084
|
-
return this.
|
|
1085
|
-
? this.getCommandsInDocumentV2(document)
|
|
1086
|
-
: this.getCommandsInDocumentV1(document);
|
|
964
|
+
return this.getCommandsInDocumentV2(document);
|
|
1087
965
|
};
|
|
1088
966
|
KustoLanguageService.prototype.getCommandsInDocumentV1 = function (document) {
|
|
1089
967
|
this.parseDocumentV1(document, k.ParseMode.CommandTokensOnly);
|
|
@@ -1183,7 +1061,7 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
1183
1061
|
});
|
|
1184
1062
|
};
|
|
1185
1063
|
KustoLanguageService.prototype.findDefinition = function (document, position) {
|
|
1186
|
-
if (!document
|
|
1064
|
+
if (!document) {
|
|
1187
1065
|
return Promise.resolve([]);
|
|
1188
1066
|
}
|
|
1189
1067
|
var script = this.parseDocumentV2(document);
|
|
@@ -1205,7 +1083,7 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
1205
1083
|
return Promise.resolve([location]);
|
|
1206
1084
|
};
|
|
1207
1085
|
KustoLanguageService.prototype.findReferences = function (document, position) {
|
|
1208
|
-
if (!document
|
|
1086
|
+
if (!document) {
|
|
1209
1087
|
return Promise.resolve([]);
|
|
1210
1088
|
}
|
|
1211
1089
|
var script = this.parseDocumentV2(document);
|
|
@@ -1229,10 +1107,9 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
1229
1107
|
return Promise.resolve(references);
|
|
1230
1108
|
};
|
|
1231
1109
|
KustoLanguageService.prototype.getQueryParams = function (document, cursorOffset) {
|
|
1232
|
-
if (!document
|
|
1110
|
+
if (!document) {
|
|
1233
1111
|
return Promise.resolve([]);
|
|
1234
1112
|
}
|
|
1235
|
-
var script = this.parseDocumentV2(document);
|
|
1236
1113
|
var parsedAndAnalyzed = this.parseAndAnalyze(document, cursorOffset);
|
|
1237
1114
|
var queryParamStatements = this.toArray(parsedAndAnalyzed.Syntax.GetDescendants(Kusto.Language.Syntax.QueryParametersStatement));
|
|
1238
1115
|
if (!queryParamStatements || queryParamStatements.length == 0) {
|
|
@@ -1373,16 +1250,13 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
1373
1250
|
return Promise.resolve(result);
|
|
1374
1251
|
};
|
|
1375
1252
|
KustoLanguageService.prototype.getGlobalParams = function (document) {
|
|
1376
|
-
if (!this.isIntellisenseV2()) {
|
|
1377
|
-
return Promise.resolve([]);
|
|
1378
|
-
}
|
|
1379
1253
|
var params = this.toArray(this._kustoJsSchemaV2.Parameters);
|
|
1380
1254
|
var result = params.map(function (param) { return ({ name: param.Name, type: param.Type.Name }); });
|
|
1381
1255
|
return Promise.resolve(result);
|
|
1382
1256
|
};
|
|
1383
1257
|
KustoLanguageService.prototype.doRename = function (document, position, newName) {
|
|
1384
1258
|
var _a;
|
|
1385
|
-
if (!document
|
|
1259
|
+
if (!document) {
|
|
1386
1260
|
return Promise.resolve(undefined);
|
|
1387
1261
|
}
|
|
1388
1262
|
var script = this.parseDocumentV2(document);
|
|
@@ -1409,7 +1283,7 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
1409
1283
|
return Promise.resolve(workspaceEdit);
|
|
1410
1284
|
};
|
|
1411
1285
|
KustoLanguageService.prototype.doHover = function (document, position) {
|
|
1412
|
-
if (!document
|
|
1286
|
+
if (!document) {
|
|
1413
1287
|
return Promise.resolve(undefined);
|
|
1414
1288
|
}
|
|
1415
1289
|
var script = this.parseDocumentV2(document);
|
|
@@ -1685,28 +1559,6 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
1685
1559
|
var newRange = ls.Range.create(range.start, newEndPosition);
|
|
1686
1560
|
return newRange;
|
|
1687
1561
|
};
|
|
1688
|
-
/**
|
|
1689
|
-
* Maps numbers to strings, such that if a>b numerically, f(a)>f(b) lexicographically.
|
|
1690
|
-
* 1 -> "a", 26 -> "z", 27 -> "za", 28 -> "zb", 52 -> "zz", 53 ->"zza"
|
|
1691
|
-
* @param order - The number to be converted to a sorting-string. order should start at 1.
|
|
1692
|
-
* @returns A string repenting the order.
|
|
1693
|
-
*/
|
|
1694
|
-
KustoLanguageService.prototype.getSortText = function (order) {
|
|
1695
|
-
if (order <= 0) {
|
|
1696
|
-
throw new RangeError("order should be a number >= 1. instead got ".concat(order));
|
|
1697
|
-
}
|
|
1698
|
-
var sortText = '';
|
|
1699
|
-
var numCharacters = 26; // "z" - "a" + 1;
|
|
1700
|
-
var div = Math.floor(order / numCharacters);
|
|
1701
|
-
for (var i = 0; i < div; ++i) {
|
|
1702
|
-
sortText += 'z';
|
|
1703
|
-
}
|
|
1704
|
-
var reminder = order % numCharacters;
|
|
1705
|
-
if (reminder > 0) {
|
|
1706
|
-
sortText += String.fromCharCode(96 + reminder);
|
|
1707
|
-
}
|
|
1708
|
-
return sortText;
|
|
1709
|
-
};
|
|
1710
1562
|
/**
|
|
1711
1563
|
* ParseTextV1 parses the given text with the given parse mode.
|
|
1712
1564
|
* Additionally - it will make sure not to provide rules provider for non-engine clusters
|
|
@@ -1852,7 +1704,7 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
1852
1704
|
return conversion || k2.ClassificationKind.PlainText;
|
|
1853
1705
|
};
|
|
1854
1706
|
KustoLanguageService.prototype.parseAndAnalyze = function (document, cursorOffset) {
|
|
1855
|
-
if (!document
|
|
1707
|
+
if (!document) {
|
|
1856
1708
|
return undefined;
|
|
1857
1709
|
}
|
|
1858
1710
|
var script = this.parseDocumentV2(document);
|
|
@@ -1895,7 +1747,6 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
1895
1747
|
}());
|
|
1896
1748
|
var languageService = new KustoLanguageService(KustoLanguageService.dummySchema, {
|
|
1897
1749
|
includeControlCommands: true,
|
|
1898
|
-
useIntellisenseV2: true,
|
|
1899
1750
|
useSemanticColorization: true,
|
|
1900
1751
|
completionOptions: { includeExtendedSyntax: false },
|
|
1901
1752
|
});
|
|
@@ -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),
|
|
@@ -3,7 +3,6 @@ export interface LanguageSettings {
|
|
|
3
3
|
includeControlCommands?: boolean;
|
|
4
4
|
newlineAfterPipe?: boolean;
|
|
5
5
|
openSuggestionDialogAfterPreviousSuggestionAccepted?: boolean;
|
|
6
|
-
useIntellisenseV2: boolean;
|
|
7
6
|
useSemanticColorization?: boolean;
|
|
8
7
|
useTokenColorization?: boolean;
|
|
9
8
|
disabledCompletionItems?: string[];
|
|
@@ -53,7 +53,6 @@ var defaultLanguageSettings = {
|
|
|
53
53
|
includeControlCommands: true,
|
|
54
54
|
newlineAfterPipe: true,
|
|
55
55
|
openSuggestionDialogAfterPreviousSuggestionAccepted: true,
|
|
56
|
-
useIntellisenseV2: true,
|
|
57
56
|
useSemanticColorization: true,
|
|
58
57
|
useTokenColorization: false,
|
|
59
58
|
enableHover: true,
|
|
@@ -98,21 +97,21 @@ monaco.editor.defineTheme(themeNames.light, {
|
|
|
98
97
|
base: 'vs',
|
|
99
98
|
inherit: true,
|
|
100
99
|
rules: [
|
|
101
|
-
{ token: 'comment', foreground: '008000' },
|
|
102
|
-
{ token: 'variable.predefined', foreground: '800080' },
|
|
103
|
-
{ token: 'function', foreground: '0000FF' },
|
|
104
|
-
{ token: 'operator.sql', foreground: 'CC3700' },
|
|
105
|
-
{ token: 'string', foreground: 'B22222' },
|
|
106
|
-
{ token: 'operator.scss', foreground: '0000FF' },
|
|
107
|
-
{ token: 'variable', foreground: 'C71585' },
|
|
108
|
-
{ token: 'variable.parameter', foreground: '9932CC' },
|
|
109
|
-
{ token: '', foreground: '000000' },
|
|
110
|
-
{ token: 'type', foreground: '0000FF' },
|
|
111
|
-
{ token: 'tag', foreground: '0000FF' },
|
|
112
|
-
{ token: 'annotation', foreground: '2B91AF' },
|
|
113
|
-
{ token: 'keyword', foreground: '0000FF' },
|
|
114
|
-
{ token: 'number', foreground: '191970' },
|
|
115
|
-
{ 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
|
|
116
115
|
{ token: 'invalid', background: 'cd3131' },
|
|
117
116
|
],
|
|
118
117
|
colors: {},
|
|
@@ -121,21 +120,21 @@ monaco.editor.defineTheme(themeNames.dark, {
|
|
|
121
120
|
base: 'vs-dark',
|
|
122
121
|
inherit: true,
|
|
123
122
|
rules: [
|
|
124
|
-
{ token: 'comment', foreground: '608B4E' },
|
|
125
|
-
{ token: 'variable.predefined', foreground: '4ec9b0' },
|
|
126
|
-
{ token: 'function', foreground: 'dcdcaa' },
|
|
127
|
-
{ token: 'operator.sql', foreground: '9cdcfe' },
|
|
128
|
-
{ token: 'string', foreground: 'ce9178' },
|
|
129
|
-
{ token: 'operator.scss', foreground: '569cd6' },
|
|
130
|
-
{ token: 'variable', foreground: '4ec9b0' },
|
|
131
|
-
{ token: 'variable.parameter', foreground: 'c586c0' },
|
|
132
|
-
{ token: '', foreground: 'd4d4d4' },
|
|
133
|
-
{ token: 'type', foreground: '569cd6' },
|
|
134
|
-
{ token: 'tag', foreground: '569cd6' },
|
|
135
|
-
{ token: 'annotation', foreground: '9cdcfe' },
|
|
136
|
-
{ token: 'keyword', foreground: '569cd6' },
|
|
137
|
-
{ token: 'number', foreground: 'd7ba7d' },
|
|
138
|
-
{ 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
|
|
139
138
|
{ token: 'invalid', background: 'cd3131' },
|
|
140
139
|
],
|
|
141
140
|
colors: {
|
|
@@ -148,7 +147,7 @@ monaco.editor.defineTheme(themeNames.dark2, {
|
|
|
148
147
|
rules: [],
|
|
149
148
|
colors: {
|
|
150
149
|
// see: https://code.visualstudio.com/api/references/theme-color#editor-widget-colors
|
|
151
|
-
'editor.background': '#1B1A19',
|
|
150
|
+
'editor.background': '#1B1A19', // gray 200
|
|
152
151
|
'editorSuggestWidget.selectedBackground': '#004E8C',
|
|
153
152
|
},
|
|
154
153
|
});
|