@kusto/monaco-kusto 5.3.10 → 5.3.12
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/package.json +7 -12
- package/release/dev/kustoMode.js +86 -32
- package/release/dev/kustoWorker.js +71 -57
- package/release/dev/monaco.contribution.js +9 -8
- package/release/esm/extendedEditor.js +3 -3
- package/release/esm/kustoMode.js +4 -1
- package/release/esm/kustoWorker.js +9 -9
- package/release/esm/languageFeatures.js +10 -10
- package/release/esm/languageService/kustoLanguageService.js +40 -34
- package/release/esm/languageService/kustoMonarchLanguageDefinition.js +72 -21
- package/release/esm/languageService/schema.js +8 -8
- package/release/esm/monaco.contribution.d.ts +1 -0
- package/release/esm/monaco.contribution.js +5 -4
- package/release/esm/monaco.d.ts +25 -15
- package/release/min/kustoMode.js +2 -11
- package/release/min/kustoWorker.js +2 -55
- package/release/min/monaco.contribution.d.ts +1 -0
- package/release/min/monaco.contribution.js +2 -2
- package/release/min/monaco.d.ts +25 -15
- package/scripts/bundle.js +55 -48
- package/scripts/release.js +13 -20
- package/tsconfig.esm.json +18 -0
- package/tsconfig.json +20 -0
- package/tsconfig.watch.json +8 -0
|
@@ -95,13 +95,12 @@ define('vs/language/kusto/commandFormatter',["require", "exports"], function (re
|
|
|
95
95
|
exports.default = KustoCommandFormatter;
|
|
96
96
|
});
|
|
97
97
|
|
|
98
|
-
/// <reference path="../node_modules/monaco-editor-core/monaco.d.ts" />
|
|
99
98
|
define('vs/language/kusto/extendedEditor',["require", "exports"], function (require, exports) {
|
|
100
99
|
"use strict";
|
|
101
100
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
102
101
|
exports.extend = void 0;
|
|
103
102
|
/**
|
|
104
|
-
* Extending ICode editor to contain additional kusto-
|
|
103
|
+
* Extending ICode editor to contain additional kusto-specific methods.
|
|
105
104
|
* note that the extend method needs to be called at least once to take affect, otherwise this here code is useless.
|
|
106
105
|
*/
|
|
107
106
|
function extend(editor) {
|
|
@@ -122,7 +121,8 @@ define('vs/language/kusto/extendedEditor',["require", "exports"], function (requ
|
|
|
122
121
|
linesWithCommandOrdinal.push({ commandOrdinal: commandOrdinal, lineNumber: lineNumber });
|
|
123
122
|
}
|
|
124
123
|
// No need to keep scanning if we're past our line and we've seen an empty line.
|
|
125
|
-
if (lineNumber > zeroBasedCursorLineNumber &&
|
|
124
|
+
if (lineNumber > zeroBasedCursorLineNumber &&
|
|
125
|
+
commandOrdinal > linesWithCommandOrdinal[zeroBasedCursorLineNumber].commandOrdinal) {
|
|
126
126
|
break;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
@@ -204,7 +204,7 @@ define('vs/language/kusto/monaco.contribution',["require", "exports", "./command
|
|
|
204
204
|
},
|
|
205
205
|
enableQueryWarnings: false,
|
|
206
206
|
enableQuerySuggestions: false,
|
|
207
|
-
|
|
207
|
+
disabledDiagnosticCodes: [],
|
|
208
208
|
};
|
|
209
209
|
function getKustoWorker() {
|
|
210
210
|
return new Promise(function (resolve, reject) {
|
|
@@ -232,7 +232,7 @@ define('vs/language/kusto/monaco.contribution',["require", "exports", "./command
|
|
|
232
232
|
id: 'kusto',
|
|
233
233
|
extensions: ['.csl', '.kql'],
|
|
234
234
|
});
|
|
235
|
-
// TODO: asked if there's a cleaner way to register an editor contribution. looks like monaco has an internal contribution
|
|
235
|
+
// TODO: asked if there's a cleaner way to register an editor contribution. looks like monaco has an internal contribution registrar but it's no exposed in the API.
|
|
236
236
|
// https://stackoverflow.com/questions/46700245/how-to-add-an-ieditorcontribution-to-monaco-editor
|
|
237
237
|
var commandHighlighter;
|
|
238
238
|
var commandFormatter;
|
|
@@ -298,7 +298,7 @@ define('vs/language/kusto/monaco.contribution',["require", "exports", "./command
|
|
|
298
298
|
// Most other language features are initialized in kustoMode.ts
|
|
299
299
|
monacoInstance.editor.onDidCreateEditor(function (editor) {
|
|
300
300
|
// hook up extension methods to editor.
|
|
301
|
-
extendedEditor_1.extend(editor);
|
|
301
|
+
(0, extendedEditor_1.extend)(editor);
|
|
302
302
|
commandHighlighter = new commandHighlighter_1.default(editor);
|
|
303
303
|
if (isStandaloneCodeEditor(editor)) {
|
|
304
304
|
commandFormatter = new commandFormatter_1.default(editor);
|
|
@@ -307,14 +307,15 @@ define('vs/language/kusto/monaco.contribution',["require", "exports", "./command
|
|
|
307
307
|
});
|
|
308
308
|
function triggerSuggestDialogWhenCompletionItemSelected(editor) {
|
|
309
309
|
editor.onDidChangeCursorSelection(function (event) {
|
|
310
|
-
// checking the condition inside the event makes sure we will stay up to date
|
|
310
|
+
// checking the condition inside the event makes sure we will stay up to date when kusto configuration changes at runtime.
|
|
311
311
|
if (kustoDefaults &&
|
|
312
312
|
kustoDefaults.languageSettings &&
|
|
313
313
|
kustoDefaults.languageSettings.openSuggestionDialogAfterPreviousSuggestionAccepted) {
|
|
314
314
|
var didAcceptSuggestion = event.source === 'snippet' && event.reason === monaco.editor.CursorChangeReason.NotSet;
|
|
315
315
|
// If the word at the current position is not null - meaning we did not add a space after completion.
|
|
316
316
|
// In this case we don't want to activate the eager mode, since it will display the current selected word..
|
|
317
|
-
if (!didAcceptSuggestion ||
|
|
317
|
+
if (!didAcceptSuggestion ||
|
|
318
|
+
editor.getModel().getWordAtPosition(event.selection.getPosition()) !== null) {
|
|
318
319
|
return;
|
|
319
320
|
}
|
|
320
321
|
event.selection;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
/// <reference path="../node_modules/monaco-editor-core/monaco.d.ts" />
|
|
2
1
|
/**
|
|
3
|
-
* Extending ICode editor to contain additional kusto-
|
|
2
|
+
* Extending ICode editor to contain additional kusto-specific methods.
|
|
4
3
|
* note that the extend method needs to be called at least once to take affect, otherwise this here code is useless.
|
|
5
4
|
*/
|
|
6
5
|
export function extend(editor) {
|
|
@@ -21,7 +20,8 @@ export function extend(editor) {
|
|
|
21
20
|
linesWithCommandOrdinal.push({ commandOrdinal: commandOrdinal, lineNumber: lineNumber });
|
|
22
21
|
}
|
|
23
22
|
// No need to keep scanning if we're past our line and we've seen an empty line.
|
|
24
|
-
if (lineNumber > zeroBasedCursorLineNumber &&
|
|
23
|
+
if (lineNumber > zeroBasedCursorLineNumber &&
|
|
24
|
+
commandOrdinal > linesWithCommandOrdinal[zeroBasedCursorLineNumber].commandOrdinal) {
|
|
25
25
|
break;
|
|
26
26
|
}
|
|
27
27
|
}
|
package/release/esm/kustoMode.js
CHANGED
|
@@ -46,7 +46,10 @@ export function setupMode(defaults, monacoInstance) {
|
|
|
46
46
|
return (__assign(__assign({}, worker), { setSchema: function (schema) { return augmentedSetSchema(schema, worker); }, setSchemaFromShowSchema: function (schema, connection, database, globalScalarParameters, globalTabularParameters) {
|
|
47
47
|
worker
|
|
48
48
|
.normalizeSchema(schema, connection, database)
|
|
49
|
-
.then(function (schema) {
|
|
49
|
+
.then(function (schema) {
|
|
50
|
+
return globalScalarParameters
|
|
51
|
+
? __assign(__assign({}, schema), { globalScalarParameters: globalScalarParameters, globalTabularParameters: globalTabularParameters }) : schema;
|
|
52
|
+
})
|
|
50
53
|
.then(function (normalized) { return augmentedSetSchema(normalized, worker); });
|
|
51
54
|
} }));
|
|
52
55
|
});
|
|
@@ -14,7 +14,7 @@ var KustoWorker = /** @class */ (function () {
|
|
|
14
14
|
KustoWorker.prototype.addClusterToSchema = function (uri, clusterName, databasesNames) {
|
|
15
15
|
var document = this._getTextDocument(uri);
|
|
16
16
|
if (!document) {
|
|
17
|
-
console.error("addClusterToSchema: document is "
|
|
17
|
+
console.error("addClusterToSchema: document is ".concat(document, ". uri is ").concat(uri));
|
|
18
18
|
return Promise.resolve();
|
|
19
19
|
}
|
|
20
20
|
return this._languageService.addClusterToSchema(document, clusterName, databasesNames);
|
|
@@ -22,7 +22,7 @@ var KustoWorker = /** @class */ (function () {
|
|
|
22
22
|
KustoWorker.prototype.addDatabaseToSchema = function (uri, clusterName, databaseSchema) {
|
|
23
23
|
var document = this._getTextDocument(uri);
|
|
24
24
|
if (!document) {
|
|
25
|
-
console.error("addDatabaseToSchema: document is "
|
|
25
|
+
console.error("addDatabaseToSchema: document is ".concat(document, ". uri is ").concat(uri));
|
|
26
26
|
return Promise.resolve();
|
|
27
27
|
}
|
|
28
28
|
return this._languageService.addDatabaseToSchema(document, clusterName, databaseSchema);
|
|
@@ -39,7 +39,7 @@ var KustoWorker = /** @class */ (function () {
|
|
|
39
39
|
KustoWorker.prototype.getCommandInContext = function (uri, cursorOffset) {
|
|
40
40
|
var document = this._getTextDocument(uri);
|
|
41
41
|
if (!document) {
|
|
42
|
-
console.error("getCommandInContext: document is "
|
|
42
|
+
console.error("getCommandInContext: document is ".concat(document, ". uri is ").concat(uri));
|
|
43
43
|
return null;
|
|
44
44
|
}
|
|
45
45
|
var commandInContext = this._languageService.getCommandInContext(document, cursorOffset);
|
|
@@ -51,7 +51,7 @@ var KustoWorker = /** @class */ (function () {
|
|
|
51
51
|
KustoWorker.prototype.getQueryParams = function (uri, cursorOffset) {
|
|
52
52
|
var document = this._getTextDocument(uri);
|
|
53
53
|
if (!document) {
|
|
54
|
-
console.error("getQueryParams: document is "
|
|
54
|
+
console.error("getQueryParams: document is ".concat(document, ". uri is ").concat(uri));
|
|
55
55
|
return null;
|
|
56
56
|
}
|
|
57
57
|
var queryParams = this._languageService.getQueryParams(document, cursorOffset);
|
|
@@ -63,7 +63,7 @@ var KustoWorker = /** @class */ (function () {
|
|
|
63
63
|
KustoWorker.prototype.getGlobalParams = function (uri) {
|
|
64
64
|
var document = this._getTextDocument(uri);
|
|
65
65
|
if (!document) {
|
|
66
|
-
console.error("getGLobalParams: document is "
|
|
66
|
+
console.error("getGLobalParams: document is ".concat(document, ". uri is ").concat(uri));
|
|
67
67
|
return null;
|
|
68
68
|
}
|
|
69
69
|
var globalParams = this._languageService.getGlobalParams(document);
|
|
@@ -75,7 +75,7 @@ var KustoWorker = /** @class */ (function () {
|
|
|
75
75
|
KustoWorker.prototype.getReferencedGlobalParams = function (uri, cursorOffest) {
|
|
76
76
|
var document = this._getTextDocument(uri);
|
|
77
77
|
if (!document) {
|
|
78
|
-
console.error("getReferencedGlobalParams: document is "
|
|
78
|
+
console.error("getReferencedGlobalParams: document is ".concat(document, ". uri is ").concat(uri));
|
|
79
79
|
return null;
|
|
80
80
|
}
|
|
81
81
|
var referencedParams = this._languageService.getReferencedGlobalParams(document, cursorOffest);
|
|
@@ -87,7 +87,7 @@ var KustoWorker = /** @class */ (function () {
|
|
|
87
87
|
KustoWorker.prototype.getRenderInfo = function (uri, cursorOffset) {
|
|
88
88
|
var document = this._getTextDocument(uri);
|
|
89
89
|
if (!document) {
|
|
90
|
-
console.error("getRenderInfo: document is "
|
|
90
|
+
console.error("getRenderInfo: document is ".concat(document, ". uri is ").concat(uri));
|
|
91
91
|
}
|
|
92
92
|
return this._languageService.getRenderInfo(document, cursorOffset).then(function (result) {
|
|
93
93
|
if (!result) {
|
|
@@ -105,7 +105,7 @@ var KustoWorker = /** @class */ (function () {
|
|
|
105
105
|
KustoWorker.prototype.getCommandAndLocationInContext = function (uri, cursorOffset) {
|
|
106
106
|
var document = this._getTextDocument(uri);
|
|
107
107
|
if (!document) {
|
|
108
|
-
console.error("getCommandAndLocationInContext: document is "
|
|
108
|
+
console.error("getCommandAndLocationInContext: document is ".concat(document, ". uri is ").concat(uri));
|
|
109
109
|
return Promise.resolve(null);
|
|
110
110
|
}
|
|
111
111
|
return this._languageService.getCommandAndLocationInContext(document, cursorOffset).then(function (result) {
|
|
@@ -124,7 +124,7 @@ var KustoWorker = /** @class */ (function () {
|
|
|
124
124
|
KustoWorker.prototype.getCommandsInDocument = function (uri) {
|
|
125
125
|
var document = this._getTextDocument(uri);
|
|
126
126
|
if (!document) {
|
|
127
|
-
console.error("getCommandInDocument: document is "
|
|
127
|
+
console.error("getCommandInDocument: document is ".concat(document, ". uri is ").concat(uri));
|
|
128
128
|
return null;
|
|
129
129
|
}
|
|
130
130
|
return this._languageService.getCommandsInDocument(document);
|
|
@@ -3,7 +3,6 @@ import * as _ from './_deps/lodash/lodash';
|
|
|
3
3
|
var Uri = monaco.Uri;
|
|
4
4
|
var Range = monaco.Range;
|
|
5
5
|
var ClassificationKind = Kusto.Language.Editor.ClassificationKind;
|
|
6
|
-
// --- diagnostics ---
|
|
7
6
|
var DiagnosticsAdapter = /** @class */ (function () {
|
|
8
7
|
function DiagnosticsAdapter(_monacoInstance, _languageId, _worker, defaults, onSchemaChange) {
|
|
9
8
|
var _this = this;
|
|
@@ -146,9 +145,9 @@ var DiagnosticsAdapter = /** @class */ (function () {
|
|
|
146
145
|
}
|
|
147
146
|
else {
|
|
148
147
|
// Add custom popup for syntax error: icon, header and message as markdown
|
|
149
|
-
var header = syntaxErrorAsMarkDown.header ? "**"
|
|
150
|
-
var icon = syntaxErrorAsMarkDown.icon ? " : '';
|
|
149
|
+
var icon = syntaxErrorAsMarkDown.icon ? "") : '';
|
|
150
|
+
var popupErrorHoverHeaderMessage_1 = "".concat(icon, " ").concat(header);
|
|
152
151
|
var newDecorations = markers.map(function (marker) {
|
|
153
152
|
return {
|
|
154
153
|
range: {
|
|
@@ -175,8 +174,7 @@ var DiagnosticsAdapter = /** @class */ (function () {
|
|
|
175
174
|
},
|
|
176
175
|
};
|
|
177
176
|
});
|
|
178
|
-
var oldMarkers = monaco.editor
|
|
179
|
-
.getModelMarkers({
|
|
177
|
+
var oldMarkers = monaco.editor.getModelMarkers({
|
|
180
178
|
owner: languageId,
|
|
181
179
|
resource: resource,
|
|
182
180
|
});
|
|
@@ -482,7 +480,7 @@ function getCssForClassification() {
|
|
|
482
480
|
var classificationColorTriplets = getClassificationColorTriplets();
|
|
483
481
|
var cssInnerHtml = classificationColorTriplets
|
|
484
482
|
.map(function (pair) {
|
|
485
|
-
return ".vs ."
|
|
483
|
+
return ".vs .".concat(pair.classification, " {color: #").concat(pair.colorLight, ";} .vs-dark .").concat(pair.classification, " {color: #").concat(pair.colorDark, ";}");
|
|
486
484
|
})
|
|
487
485
|
.join('\n');
|
|
488
486
|
return cssInnerHtml;
|
|
@@ -583,7 +581,7 @@ function toTextEdit(textEdit) {
|
|
|
583
581
|
text: textEdit.newText,
|
|
584
582
|
};
|
|
585
583
|
}
|
|
586
|
-
var DOCS_BASE_URL =
|
|
584
|
+
var DOCS_BASE_URL = 'https://learn.microsoft.com/azure/data-explorer/kusto/query';
|
|
587
585
|
function formatDocLink(docString) {
|
|
588
586
|
// If the docString is empty, we want to return undefined to prevent an empty documentation popup.
|
|
589
587
|
if (!docString) {
|
|
@@ -593,9 +591,11 @@ function formatDocLink(docString) {
|
|
|
593
591
|
var urisProxy = new Proxy(target, {
|
|
594
592
|
get: function (_target, prop, _receiver) {
|
|
595
593
|
// The link comes with a postfix of ".md" that we want to remove
|
|
596
|
-
var linkWithoutPostfix = prop.toString().replace(
|
|
594
|
+
var linkWithoutPostfix = prop.toString().replace('.md', '');
|
|
597
595
|
// Sometimes we get the link as a full URL. For example in the main doc link of the item
|
|
598
|
-
var fullURL = linkWithoutPostfix.startsWith(
|
|
596
|
+
var fullURL = linkWithoutPostfix.startsWith('https')
|
|
597
|
+
? linkWithoutPostfix
|
|
598
|
+
: "".concat(DOCS_BASE_URL, "/").concat(linkWithoutPostfix);
|
|
599
599
|
return monaco.Uri.parse(fullURL);
|
|
600
600
|
},
|
|
601
601
|
});
|
|
@@ -9,16 +9,15 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
+
if (ar || !(i in from)) {
|
|
15
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
+
ar[i] = from[i];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
18
20
|
};
|
|
19
|
-
/// <reference path="../../node_modules/@kusto/language-service/Kusto.JavaScript.Client.d.ts" />
|
|
20
|
-
/// <reference path="../../node_modules/@kusto/language-service-next/Kusto.Language.Bridge.d.ts" />
|
|
21
|
-
/// <reference path="../typings/refs.d.ts" />
|
|
22
21
|
import * as s from './schema';
|
|
23
22
|
// polyfill string endsWith
|
|
24
23
|
if (!String.prototype.endsWith) {
|
|
@@ -124,7 +123,7 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
124
123
|
/**
|
|
125
124
|
* Taken from:
|
|
126
125
|
* 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
|
|
127
|
-
|
|
126
|
+
*/
|
|
128
127
|
this._toOptionKind = (_a = {},
|
|
129
128
|
_a[k2.CompletionKind.AggregateFunction] = k.OptionKind.FunctionAggregation,
|
|
130
129
|
_a[k2.CompletionKind.BuiltInFunction] = k.OptionKind.FunctionScalar,
|
|
@@ -271,7 +270,7 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
271
270
|
this._newlineAppendPipePolicy.Text = '\n| ';
|
|
272
271
|
}
|
|
273
272
|
KustoLanguageService.prototype.createDatabaseUniqueName = function (clusterName, databaseName) {
|
|
274
|
-
return clusterName
|
|
273
|
+
return "".concat(clusterName, "_").concat(databaseName);
|
|
275
274
|
};
|
|
276
275
|
Object.defineProperty(KustoLanguageService.prototype, "_kustoJsSchemaV2", {
|
|
277
276
|
/**
|
|
@@ -318,20 +317,20 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
318
317
|
*/
|
|
319
318
|
KustoLanguageService.prototype.debugGlobalState = function (globals) {
|
|
320
319
|
// iterate over clusters
|
|
321
|
-
console.log("globals.Clusters.Count: "
|
|
320
|
+
console.log("globals.Clusters.Count: ".concat(globals.Clusters.Count));
|
|
322
321
|
for (var i = 0; i < globals.Clusters.Count; i++) {
|
|
323
322
|
var cluster = globals.Clusters.getItem(i);
|
|
324
|
-
console.log("cluster: "
|
|
323
|
+
console.log("cluster: ".concat(cluster.Name));
|
|
325
324
|
// iterate over databases
|
|
326
|
-
console.log("cluster.Databases.Count: "
|
|
325
|
+
console.log("cluster.Databases.Count: ".concat(cluster.Databases.Count));
|
|
327
326
|
for (var i2 = 0; i2 < cluster.Databases.Count; i2++) {
|
|
328
327
|
var database = cluster.Databases.getItem(i2);
|
|
329
|
-
console.log("cluster.database: ["
|
|
328
|
+
console.log("cluster.database: [".concat(cluster.Name, "].[").concat(database.Name, "]"));
|
|
330
329
|
// iterate over tables
|
|
331
|
-
console.log("cluster.Databases.Tables.Count: "
|
|
330
|
+
console.log("cluster.Databases.Tables.Count: ".concat(database.Tables.Count));
|
|
332
331
|
for (var i3 = 0; i3 < database.Tables.Count; i3++) {
|
|
333
332
|
var table = database.Tables.getItem(i3);
|
|
334
|
-
console.log("cluster.database.table: ["
|
|
333
|
+
console.log("cluster.database.table: [".concat(cluster.Name, "].[").concat(database.Name, "].[").concat(table.Name, "]"));
|
|
335
334
|
}
|
|
336
335
|
}
|
|
337
336
|
}
|
|
@@ -340,7 +339,7 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
340
339
|
* Prepending the doc of the actual topic at the top
|
|
341
340
|
*/
|
|
342
341
|
KustoLanguageService.prototype.formatHelpTopic = function (helpTopic) {
|
|
343
|
-
return "**"
|
|
342
|
+
return "**".concat(helpTopic.Name, " [(view online)](").concat(helpTopic.Url, ")**\n\n").concat(helpTopic.LongDescription);
|
|
344
343
|
};
|
|
345
344
|
KustoLanguageService.prototype.doCompleteV2 = function (document, position) {
|
|
346
345
|
var _this = this;
|
|
@@ -382,7 +381,7 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
382
381
|
? {
|
|
383
382
|
// Need to escape dollar sign since it is used as a placeholder in snippet.
|
|
384
383
|
// Usually dollar sign is not a valid character in a function name, but grafana uses macros that start with dollars.
|
|
385
|
-
textToInsert: kItem.EditText.replace('$', '\\$')
|
|
384
|
+
textToInsert: "".concat(kItem.EditText.replace('$', '\\$'), "$0").concat(kItem.AfterText),
|
|
386
385
|
format: ls.InsertTextFormat.Snippet,
|
|
387
386
|
}
|
|
388
387
|
: {
|
|
@@ -786,13 +785,14 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
786
785
|
KustoLanguageService.prototype.setSchema = function (schema) {
|
|
787
786
|
var _this = this;
|
|
788
787
|
this._schema = schema;
|
|
789
|
-
if
|
|
790
|
-
|
|
788
|
+
// We support intellisenseV2 only if the clusterType is "Engine", even if the setting is enabled
|
|
789
|
+
if (this._languageSettings.useIntellisenseV2 && schema && schema.clusterType === 'Engine') {
|
|
790
|
+
var kustoJsSchemaV2 = this.convertToKustoJsSchemaV2(schema);
|
|
791
791
|
this._kustoJsSchemaV2 = kustoJsSchemaV2;
|
|
792
792
|
this._script = undefined;
|
|
793
793
|
this._parsePropertiesV2 = undefined;
|
|
794
794
|
}
|
|
795
|
-
// since V2 doesn't support control commands, we're initializing V1 intellisense for both cases and we'll going to use V1 intellisense for
|
|
795
|
+
// since V2 doesn't support control commands, we're initializing V1 intellisense for both cases and we'll going to use V1 intellisense for control commands.
|
|
796
796
|
return new Promise(function (resolve, reject) {
|
|
797
797
|
var kustoJsSchema = schema ? KustoLanguageService.convertToKustoJsSchema(schema) : undefined;
|
|
798
798
|
_this._kustoJsSchema = kustoJsSchema;
|
|
@@ -807,8 +807,10 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
807
807
|
this._schema.globalScalarParameters = scalarParameters;
|
|
808
808
|
this._schema.globalTabularParameters = tabularParameters;
|
|
809
809
|
var scalarSymbols = scalarParameters.map(function (param) { return KustoLanguageService.createParameterSymbol(param); });
|
|
810
|
-
var tabularSymbols = tabularParameters.map(function (param) {
|
|
811
|
-
|
|
810
|
+
var tabularSymbols = tabularParameters.map(function (param) {
|
|
811
|
+
return KustoLanguageService.createTabularParameterSymbol(param);
|
|
812
|
+
});
|
|
813
|
+
this._kustoJsSchemaV2 = this._kustoJsSchemaV2.WithParameters(KustoLanguageService.toBridgeList(__spreadArray(__spreadArray([], scalarSymbols, true), tabularSymbols, true)));
|
|
812
814
|
return Promise.resolve(undefined);
|
|
813
815
|
};
|
|
814
816
|
/**
|
|
@@ -1455,8 +1457,8 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
1455
1457
|
* @param params scalar parameters
|
|
1456
1458
|
*/
|
|
1457
1459
|
KustoLanguageService.scalarParametersToSignature = function (params) {
|
|
1458
|
-
var signatureWithoutParens = params.map(function (param) { return param.name
|
|
1459
|
-
return "("
|
|
1460
|
+
var signatureWithoutParens = params.map(function (param) { return "".concat(param.name, ": ").concat(param.cslType); }).join(', ');
|
|
1461
|
+
return "(".concat(signatureWithoutParens, ")");
|
|
1460
1462
|
};
|
|
1461
1463
|
/**
|
|
1462
1464
|
* Returns something like '(x: string, T: (y: int))'
|
|
@@ -1468,14 +1470,14 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
1468
1470
|
.map(function (param) {
|
|
1469
1471
|
if (param.columns) {
|
|
1470
1472
|
var tableSignature = _this.scalarParametersToSignature(param.columns);
|
|
1471
|
-
return param.name
|
|
1473
|
+
return "".concat(param.name, ": ").concat(tableSignature);
|
|
1472
1474
|
}
|
|
1473
1475
|
else {
|
|
1474
|
-
return param.name
|
|
1476
|
+
return "".concat(param.name, ": ").concat(param.cslType);
|
|
1475
1477
|
}
|
|
1476
1478
|
})
|
|
1477
1479
|
.join(', ');
|
|
1478
|
-
return "("
|
|
1480
|
+
return "(".concat(signatureWithoutParens, ")");
|
|
1479
1481
|
};
|
|
1480
1482
|
/**
|
|
1481
1483
|
* converts a function definition to a let statement.
|
|
@@ -1483,7 +1485,7 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
1483
1485
|
*/
|
|
1484
1486
|
KustoLanguageService.toLetStatement = function (fn) {
|
|
1485
1487
|
var signature = this.inputParameterToSignature(fn.inputParameters);
|
|
1486
|
-
return "let "
|
|
1488
|
+
return "let ".concat(fn.name, " = ").concat(signature, " ").concat(fn.body);
|
|
1487
1489
|
};
|
|
1488
1490
|
KustoLanguageService.createColumnSymbol = function (col) {
|
|
1489
1491
|
return new sym.ColumnSymbol(col.name, sym.ScalarTypes.GetSymbol(getCslTypeNameFromClrType(col.type)), col.docstring, null, null, col.examples ? KustoLanguageService.toBridgeList(col.examples) : null);
|
|
@@ -1591,11 +1593,15 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
1591
1593
|
globalState = globalState.WithDatabase(databaseInContext);
|
|
1592
1594
|
}
|
|
1593
1595
|
// Inject global scalar parameters to global scope.
|
|
1594
|
-
var scalarParameters = ((_a = schema.globalScalarParameters) !== null && _a !== void 0 ? _a : []).map(function (param) {
|
|
1596
|
+
var scalarParameters = ((_a = schema.globalScalarParameters) !== null && _a !== void 0 ? _a : []).map(function (param) {
|
|
1597
|
+
return KustoLanguageService.createParameterSymbol(param);
|
|
1598
|
+
});
|
|
1595
1599
|
// Inject global tabular parameters to global scope.
|
|
1596
|
-
var tabularParameters = ((_b = schema.globalTabularParameters) !== null && _b !== void 0 ? _b : []).map(function (param) {
|
|
1600
|
+
var tabularParameters = ((_b = schema.globalTabularParameters) !== null && _b !== void 0 ? _b : []).map(function (param) {
|
|
1601
|
+
return KustoLanguageService.createTabularParameterSymbol(param);
|
|
1602
|
+
});
|
|
1597
1603
|
if (tabularParameters.length || scalarParameters.length) {
|
|
1598
|
-
globalState = globalState.WithParameters(KustoLanguageService.toBridgeList(
|
|
1604
|
+
globalState = globalState.WithParameters(KustoLanguageService.toBridgeList(__spreadArray(__spreadArray([], scalarParameters, true), tabularParameters, true)));
|
|
1599
1605
|
}
|
|
1600
1606
|
return globalState;
|
|
1601
1607
|
};
|
|
@@ -1632,7 +1638,7 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
1632
1638
|
*/
|
|
1633
1639
|
KustoLanguageService.prototype.getSortText = function (order) {
|
|
1634
1640
|
if (order <= 0) {
|
|
1635
|
-
throw new RangeError("order should be a number >= 1. instead got "
|
|
1641
|
+
throw new RangeError("order should be a number >= 1. instead got ".concat(order));
|
|
1636
1642
|
}
|
|
1637
1643
|
var sortText = '';
|
|
1638
1644
|
var numCharacters = 26; // "z" - "a" + 1;
|
|
@@ -1,23 +1,69 @@
|
|
|
1
1
|
export var KustoLanguageDefinition = {
|
|
2
2
|
name: 'kusto',
|
|
3
3
|
mimeTypes: ['text/kusto'],
|
|
4
|
-
displayName:
|
|
5
|
-
defaultToken:
|
|
6
|
-
brackets: [
|
|
7
|
-
['
|
|
4
|
+
displayName: 'Kusto',
|
|
5
|
+
defaultToken: 'invalid',
|
|
6
|
+
brackets: [
|
|
7
|
+
['[', ']', 'delimiter.square'],
|
|
8
|
+
['(', ')', 'delimiter.parenthesis'],
|
|
9
|
+
],
|
|
8
10
|
wordDefinition: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
|
|
9
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.
|
|
10
12
|
promotedOperatorCommandTokens: Kusto.Data.IntelliSense.CslCommandParser.PromotedOperatorCommandTokens.slice(0),
|
|
11
13
|
operatorCommandTokens: Kusto.Data.IntelliSense.CslCommandParser.OperatorCommandTokens.slice(0),
|
|
12
14
|
keywords: [
|
|
13
|
-
'by',
|
|
14
|
-
'
|
|
15
|
+
'by',
|
|
16
|
+
'on',
|
|
17
|
+
'contains',
|
|
18
|
+
'notcontains',
|
|
19
|
+
'containscs',
|
|
20
|
+
'notcontainscs',
|
|
21
|
+
'startswith',
|
|
22
|
+
'has',
|
|
23
|
+
'matches',
|
|
24
|
+
'regex',
|
|
25
|
+
'true',
|
|
26
|
+
'false',
|
|
27
|
+
'and',
|
|
28
|
+
'or',
|
|
29
|
+
'typeof',
|
|
30
|
+
'int',
|
|
31
|
+
'string',
|
|
32
|
+
'date',
|
|
33
|
+
'datetime',
|
|
34
|
+
'time',
|
|
35
|
+
'long',
|
|
36
|
+
'real',
|
|
37
|
+
'boolean',
|
|
38
|
+
'bool',
|
|
15
39
|
],
|
|
16
40
|
operators: ['+', '-', '*', '/', '>', '<', '==', '<>', '<=', '>=', '~', '!~'],
|
|
17
41
|
builtinFunctions: [
|
|
18
|
-
'countof',
|
|
19
|
-
'
|
|
20
|
-
'
|
|
42
|
+
'countof',
|
|
43
|
+
'bin',
|
|
44
|
+
'extentid',
|
|
45
|
+
'extract',
|
|
46
|
+
'extractjson',
|
|
47
|
+
'floor',
|
|
48
|
+
'iif',
|
|
49
|
+
'isnull',
|
|
50
|
+
'isnotnull',
|
|
51
|
+
'notnull',
|
|
52
|
+
'isempty',
|
|
53
|
+
'isnotempty',
|
|
54
|
+
'notempty',
|
|
55
|
+
'now',
|
|
56
|
+
're2',
|
|
57
|
+
'strcat',
|
|
58
|
+
'strlen',
|
|
59
|
+
'toupper',
|
|
60
|
+
'tostring',
|
|
61
|
+
'count',
|
|
62
|
+
'cnt',
|
|
63
|
+
'sum',
|
|
64
|
+
'min',
|
|
65
|
+
'max',
|
|
66
|
+
'avg',
|
|
21
67
|
],
|
|
22
68
|
tokenizer: {
|
|
23
69
|
root: [
|
|
@@ -30,7 +76,9 @@ export var KustoLanguageDefinition = {
|
|
|
30
76
|
[/[;,.]/, 'delimiter'],
|
|
31
77
|
[/[()\[\]]/, '@brackets'],
|
|
32
78
|
[/[<>=!%&+\-*/|~^]/, 'operator'],
|
|
33
|
-
[
|
|
79
|
+
[
|
|
80
|
+
/[\w@#\-$]+/,
|
|
81
|
+
{
|
|
34
82
|
cases: {
|
|
35
83
|
'@keywords': 'keyword',
|
|
36
84
|
'@promotedOperatorCommandTokens': 'operator.sql',
|
|
@@ -38,39 +86,42 @@ export var KustoLanguageDefinition = {
|
|
|
38
86
|
'@operators': 'operator',
|
|
39
87
|
'@builtinFunctions': 'predefined',
|
|
40
88
|
'@default': 'identifier',
|
|
41
|
-
}
|
|
42
|
-
}
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
],
|
|
43
92
|
],
|
|
44
93
|
whitespace: [[/\s+/, 'white']],
|
|
45
|
-
comments: [[
|
|
94
|
+
comments: [['\\/\\/+.*', 'comment']],
|
|
46
95
|
numbers: [
|
|
47
96
|
[/0[xX][0-9a-fA-F]*/, 'number'],
|
|
48
97
|
[/[$][+-]*\d*(\.\d*)?/, 'number'],
|
|
49
|
-
[/((\d+(\.\d*)?)|(\.\d+))([eE][\-+]?\d+)?/, 'number']
|
|
98
|
+
[/((\d+(\.\d*)?)|(\.\d+))([eE][\-+]?\d+)?/, 'number'],
|
|
50
99
|
],
|
|
51
100
|
strings: [
|
|
52
101
|
[/H'/, { token: 'string.quote', bracket: '@open', next: '@string' }],
|
|
53
102
|
[/h'/, { token: 'string.quote', bracket: '@open', next: '@string' }],
|
|
54
|
-
[/'/, { token: 'string.quote', bracket: '@open', next: '@string' }]
|
|
103
|
+
[/'/, { token: 'string.quote', bracket: '@open', next: '@string' }],
|
|
55
104
|
],
|
|
56
105
|
string: [
|
|
57
106
|
[/[^']+/, 'string'],
|
|
58
107
|
[/''/, 'string'],
|
|
59
|
-
[/'/, { token: 'string.quote', bracket: '@close', next: '@pop' }]
|
|
108
|
+
[/'/, { token: 'string.quote', bracket: '@close', next: '@pop' }],
|
|
60
109
|
],
|
|
61
110
|
dqstrings: [
|
|
62
111
|
[/H"/, { token: 'string.quote', bracket: '@open', next: '@dqstring' }],
|
|
63
112
|
[/h"/, { token: 'string.quote', bracket: '@open', next: '@dqstring' }],
|
|
64
|
-
[/"/, { token: 'string.quote', bracket: '@open', next: '@dqstring' }]
|
|
113
|
+
[/"/, { token: 'string.quote', bracket: '@open', next: '@dqstring' }],
|
|
65
114
|
],
|
|
66
115
|
dqstring: [
|
|
67
116
|
[/[^"]+/, 'string'],
|
|
68
117
|
[/""/, 'string'],
|
|
69
|
-
[/"/, { token: 'string.quote', bracket: '@close', next: '@pop' }]
|
|
118
|
+
[/"/, { token: 'string.quote', bracket: '@close', next: '@pop' }],
|
|
70
119
|
],
|
|
71
|
-
literals: [
|
|
120
|
+
literals: [
|
|
121
|
+
[/datetime\(\d{4}-\d{2}-\d{2}(\s+\d{2}:\d{2}(:\d{2}(\.\d{0,3})?)?)?\)/, 'number'],
|
|
72
122
|
[/time\((\d+(s(ec(onds?)?)?|m(in(utes?)?)?|h(ours?)?|d(ays?)?)|(\s*(('[^']+')|("[^"]+"))\s*))\)/, 'number'],
|
|
73
123
|
[/guid\([\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}\)/, 'number'],
|
|
74
|
-
[/typeof\((int|string|date|datetime|time|long|real|boolean|bool)\)/, 'number']
|
|
75
|
-
|
|
124
|
+
[/typeof\((int|string|date|datetime|time|long|real|boolean|bool)\)/, 'number'],
|
|
125
|
+
],
|
|
126
|
+
},
|
|
76
127
|
};
|
|
@@ -19,7 +19,7 @@ var dotnetTypeToKustoType = {
|
|
|
19
19
|
'Newtonsoft.Json.Linq.JObject': 'dynamic',
|
|
20
20
|
'Newtonsoft.Json.Linq.JToken': 'dynamic',
|
|
21
21
|
'System.Object': 'dynamic',
|
|
22
|
-
'System.Data.SqlTypes.SqlDecimal': 'decimal'
|
|
22
|
+
'System.Data.SqlTypes.SqlDecimal': 'decimal',
|
|
23
23
|
};
|
|
24
24
|
export var getCslTypeNameFromClrType = function (clrType) { return dotnetTypeToKustoType[clrType] || clrType; };
|
|
25
25
|
var kustoTypeToEntityDataType = {
|
|
@@ -38,27 +38,27 @@ var kustoTypeToEntityDataType = {
|
|
|
38
38
|
datetime: 'DateTime',
|
|
39
39
|
string: 'String',
|
|
40
40
|
dynamic: 'Dynamic',
|
|
41
|
-
timespan: 'TimeSpan'
|
|
41
|
+
timespan: 'TimeSpan',
|
|
42
42
|
};
|
|
43
43
|
export var getEntityDataTypeFromCslType = function (cslType) { return kustoTypeToEntityDataType[cslType] || cslType; };
|
|
44
44
|
export var getCallName = function (fn) {
|
|
45
|
-
return fn.name
|
|
45
|
+
return "".concat(fn.name, "(").concat(fn.inputParameters.map(function (p) { return "{".concat(p.name, "}"); }).join(','), ")");
|
|
46
46
|
};
|
|
47
47
|
export var getExpression = function (fn) {
|
|
48
|
-
return "let "
|
|
48
|
+
return "let ".concat(fn.name, " = ").concat(getInputParametersAsCslString(fn.inputParameters), " ").concat(fn.body);
|
|
49
49
|
};
|
|
50
50
|
export var getInputParametersAsCslString = function (inputParameters) {
|
|
51
|
-
return "("
|
|
51
|
+
return "(".concat(inputParameters.map(function (inputParameter) { return getInputParameterAsCslString(inputParameter); }).join(','), ")");
|
|
52
52
|
};
|
|
53
53
|
var getInputParameterAsCslString = function (inputParameter) {
|
|
54
54
|
// If this is a tabular parameter
|
|
55
55
|
if (inputParameter.columns && inputParameter.columns.length > 0) {
|
|
56
56
|
var attributesAsString = inputParameter.columns
|
|
57
|
-
.map(function (col) { return col.name
|
|
57
|
+
.map(function (col) { return "".concat(col.name, ":").concat(col.cslType || getCslTypeNameFromClrType(col.type)); })
|
|
58
58
|
.join(',');
|
|
59
|
-
return inputParameter.name
|
|
59
|
+
return "".concat(inputParameter.name, ":").concat(attributesAsString === '' ? '*' : attributesAsString);
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
62
|
-
return inputParameter.name
|
|
62
|
+
return "".concat(inputParameter.name, ":").concat(inputParameter.cslType || getCslTypeNameFromClrType(inputParameter.type));
|
|
63
63
|
}
|
|
64
64
|
};
|