@kusto/monaco-kusto 5.3.12 → 5.5.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/package.json +3 -3
- package/release/dev/kustoMode.js +132 -0
- package/release/dev/kustoWorker.js +119 -15
- package/release/dev/monaco.contribution.js +1 -0
- package/release/esm/kustoWorker.js +18 -2
- package/release/esm/languageFeatures.js +132 -0
- package/release/esm/languageService/kustoLanguageService.js +101 -13
- package/release/esm/monaco.contribution.js +1 -0
- package/release/esm/monaco.d.ts +8 -1
- package/release/min/Kusto.Language.Bridge.min.js +1 -1
- package/release/min/kusto.javascript.client.min.js +1 -1
- package/release/min/kustoMode.js +1 -1
- package/release/min/kustoWorker.js +1 -1
- package/release/min/monaco.contribution.js +1 -1
- package/release/min/monaco.d.ts +8 -1
|
@@ -18,6 +18,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
18
18
|
}
|
|
19
19
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
20
|
};
|
|
21
|
+
var _a;
|
|
21
22
|
import * as s from './schema';
|
|
22
23
|
// polyfill string endsWith
|
|
23
24
|
if (!String.prototype.endsWith) {
|
|
@@ -102,6 +103,30 @@ function toClassifiedRange(k2Classifications) {
|
|
|
102
103
|
kind: classification.Kind,
|
|
103
104
|
}); });
|
|
104
105
|
}
|
|
106
|
+
var symbolKindToName = (_a = {},
|
|
107
|
+
_a[sym.SymbolKind.Cluster] = 'Cluster',
|
|
108
|
+
_a[sym.SymbolKind.Column] = 'Column',
|
|
109
|
+
_a[sym.SymbolKind.Command] = 'Command',
|
|
110
|
+
_a[sym.SymbolKind.Database] = 'Database',
|
|
111
|
+
_a[sym.SymbolKind.EntityGroup] = 'EntityGroup',
|
|
112
|
+
_a[sym.SymbolKind.EntityGroupElement] = 'EntityGroupElement',
|
|
113
|
+
_a[sym.SymbolKind.Error] = 'Error',
|
|
114
|
+
_a[sym.SymbolKind.Function] = 'Function',
|
|
115
|
+
_a[sym.SymbolKind.Graph] = 'Graph',
|
|
116
|
+
_a[sym.SymbolKind.Group] = 'Group',
|
|
117
|
+
_a[sym.SymbolKind.MaterializedView] = 'MaterializedView',
|
|
118
|
+
_a[sym.SymbolKind.None] = 'None',
|
|
119
|
+
_a[sym.SymbolKind.Operator] = 'Operator',
|
|
120
|
+
_a[sym.SymbolKind.Option] = 'Option',
|
|
121
|
+
_a[sym.SymbolKind.Parameter] = 'Parameter',
|
|
122
|
+
_a[sym.SymbolKind.Pattern] = 'Pattern',
|
|
123
|
+
_a[sym.SymbolKind.QueryOperatorParameter] = 'QueryOperatorParameter',
|
|
124
|
+
_a[sym.SymbolKind.Scalar] = 'Scalar',
|
|
125
|
+
_a[sym.SymbolKind.Table] = 'Table',
|
|
126
|
+
_a[sym.SymbolKind.Tuple] = 'Tuple',
|
|
127
|
+
_a[sym.SymbolKind.Variable] = 'Variable',
|
|
128
|
+
_a[sym.SymbolKind.Void] = 'Void',
|
|
129
|
+
_a);
|
|
105
130
|
/**
|
|
106
131
|
* Kusto Language service translates the kusto object model (transpiled from C# by Bridge.Net)
|
|
107
132
|
* to the vscode language server types, which are used by vscode language extensions.
|
|
@@ -618,6 +643,53 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
618
643
|
var lsDiagnostics = this.toLsDiagnostics(diagnostics, document);
|
|
619
644
|
return Promise.resolve(lsDiagnostics);
|
|
620
645
|
};
|
|
646
|
+
KustoLanguageService.prototype.getApplyCodeActions = function (document, start, end) {
|
|
647
|
+
var script = this.parseDocumentV2(document);
|
|
648
|
+
var block = this.getAffectedBlocks(this.toArray(script.Blocks), [{ start: start, end: end }])[0];
|
|
649
|
+
var codeActionInfo = block.Service.GetCodeActions(start, start, end - start + 1, null, true, null, new Kusto.Language.Utils.CancellationToken());
|
|
650
|
+
var codeActions = this.toArray(codeActionInfo.Actions);
|
|
651
|
+
// Some code actions are of type "MenuAction". We want to flat them out, to show them seperately.
|
|
652
|
+
var flatCodeActions = [];
|
|
653
|
+
for (var i = 0; i < codeActions.length; i++) {
|
|
654
|
+
flatCodeActions.push.apply(flatCodeActions, this.flattenCodeActions(codeActions[i]));
|
|
655
|
+
}
|
|
656
|
+
return flatCodeActions;
|
|
657
|
+
};
|
|
658
|
+
KustoLanguageService.prototype.getResultActions = function (document, start, end) {
|
|
659
|
+
var _this = this;
|
|
660
|
+
var script = this.parseDocumentV2(document);
|
|
661
|
+
var block = this.getAffectedBlocks(this.toArray(script.Blocks), [{ start: start, end: end }])[0];
|
|
662
|
+
var applyCodeActions = this.getApplyCodeActions(document, start, end);
|
|
663
|
+
var resultActionsMap = applyCodeActions
|
|
664
|
+
.map(function (applyCodeAction) {
|
|
665
|
+
var changes = [];
|
|
666
|
+
var codeActionResults = _this.toArray(block.Service.ApplyCodeAction(applyCodeAction, start).Actions);
|
|
667
|
+
var changeTextAction = codeActionResults.find(function (c) { return c instanceof Kusto.Language.Editor.ChangeTextAction; });
|
|
668
|
+
if (changeTextAction) {
|
|
669
|
+
changes = _this.toArray(changeTextAction.Changes).map(function (change) { return ({
|
|
670
|
+
start: change.Start + block.Start,
|
|
671
|
+
deleteLength: change.DeleteLength,
|
|
672
|
+
insertText: change.InsertText,
|
|
673
|
+
}); });
|
|
674
|
+
}
|
|
675
|
+
return { title: applyCodeAction.Title, changes: changes };
|
|
676
|
+
})
|
|
677
|
+
.filter(function (resultAction) { return resultAction.changes.length; });
|
|
678
|
+
return Promise.resolve(resultActionsMap);
|
|
679
|
+
};
|
|
680
|
+
KustoLanguageService.prototype.flattenCodeActions = function (codeAction) {
|
|
681
|
+
var applyActions = [];
|
|
682
|
+
if (codeAction instanceof k2.ApplyAction) {
|
|
683
|
+
applyActions.push(codeAction);
|
|
684
|
+
}
|
|
685
|
+
else if (codeAction instanceof k2.MenuAction) {
|
|
686
|
+
var nestedCodeActions = this.toArray(codeAction.Actions);
|
|
687
|
+
for (var i = 0; i < nestedCodeActions.length; i++) {
|
|
688
|
+
applyActions.push.apply(applyActions, this.flattenCodeActions(nestedCodeActions[i]));
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
return applyActions;
|
|
692
|
+
};
|
|
621
693
|
KustoLanguageService.prototype.toLsDiagnostics = function (diagnostics, document) {
|
|
622
694
|
return diagnostics
|
|
623
695
|
.filter(function (diag) { return diag.HasLocation; })
|
|
@@ -1211,17 +1283,30 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
1211
1283
|
};
|
|
1212
1284
|
return Promise.resolve(renderInfo);
|
|
1213
1285
|
};
|
|
1214
|
-
KustoLanguageService.prototype.
|
|
1215
|
-
|
|
1216
|
-
|
|
1286
|
+
KustoLanguageService.prototype.getReferencedSymbols = function (document, offset) {
|
|
1287
|
+
var parsedAndAnalyzed = this.parseAndAnalyze(document, offset);
|
|
1288
|
+
if (!parsedAndAnalyzed) {
|
|
1289
|
+
Promise.resolve([]);
|
|
1217
1290
|
}
|
|
1218
|
-
|
|
1219
|
-
var
|
|
1220
|
-
|
|
1221
|
-
return
|
|
1291
|
+
// We take all referenced symbols in the query
|
|
1292
|
+
var referencedSymbols = this.toArray(parsedAndAnalyzed.Syntax.GetDescendants(Kusto.Language.Syntax.Expression))
|
|
1293
|
+
.filter(function (expression) { return expression.ReferencedSymbol !== null; })
|
|
1294
|
+
.map(function (x) { return x.ReferencedSymbol; });
|
|
1295
|
+
var result = referencedSymbols.map(function (sym) {
|
|
1296
|
+
var _a;
|
|
1297
|
+
return ({
|
|
1298
|
+
name: sym.Name,
|
|
1299
|
+
kind: (_a = symbolKindToName[sym.Kind]) !== null && _a !== void 0 ? _a : "".concat(sym.Kind),
|
|
1300
|
+
display: sym.Display,
|
|
1301
|
+
});
|
|
1302
|
+
});
|
|
1303
|
+
return Promise.resolve(result);
|
|
1304
|
+
};
|
|
1305
|
+
KustoLanguageService.prototype.getReferencedGlobalParams = function (document, cursorOffset) {
|
|
1306
|
+
var parsedAndAnalyzed = this.parseAndAnalyze(document, cursorOffset);
|
|
1307
|
+
if (!parsedAndAnalyzed) {
|
|
1308
|
+
Promise.resolve([]);
|
|
1222
1309
|
}
|
|
1223
|
-
var text = currentBlock.Text;
|
|
1224
|
-
var parsedAndAnalyzed = Kusto.Language.KustoCode.ParseAndAnalyze(text, this._kustoJsSchemaV2);
|
|
1225
1310
|
// We take the ambient parameters
|
|
1226
1311
|
var ambientParameters = this.toArray(this._kustoJsSchemaV2.Parameters);
|
|
1227
1312
|
// We take all referenced symbols in the query
|
|
@@ -1801,11 +1886,14 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
1801
1886
|
return undefined;
|
|
1802
1887
|
}
|
|
1803
1888
|
var script = this.parseDocumentV2(document);
|
|
1804
|
-
var
|
|
1805
|
-
if (
|
|
1806
|
-
|
|
1889
|
+
var text = script.Text;
|
|
1890
|
+
if (cursorOffset !== undefined) {
|
|
1891
|
+
var currentBlock = this.getCurrentCommandV2(script, cursorOffset);
|
|
1892
|
+
if (!currentBlock) {
|
|
1893
|
+
return undefined;
|
|
1894
|
+
}
|
|
1895
|
+
text = currentBlock.Text;
|
|
1807
1896
|
}
|
|
1808
|
-
var text = currentBlock.Text;
|
|
1809
1897
|
var parsedAndAnalyzed = Kusto.Language.KustoCode.ParseAndAnalyze(text, this._kustoJsSchemaV2);
|
|
1810
1898
|
return parsedAndAnalyzed;
|
|
1811
1899
|
};
|
package/release/esm/monaco.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ declare module monaco.languages.kusto {
|
|
|
26
26
|
enableQueryWarnings?: boolean;
|
|
27
27
|
enableQuerySuggestions?: boolean;
|
|
28
28
|
disabledDiagnosticCodes?: string[];
|
|
29
|
+
quickFixCodeActions?: QuickFixCodeActionOptions[];
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
export interface SyntaxErrorAsMarkDownOptions {
|
|
@@ -34,6 +35,8 @@ declare module monaco.languages.kusto {
|
|
|
34
35
|
enableSyntaxErrorAsMarkDown?: boolean;
|
|
35
36
|
}
|
|
36
37
|
|
|
38
|
+
export type QuickFixCodeActionOptions = 'Extract Expression' | 'Extract Function' | 'Change to';
|
|
39
|
+
|
|
37
40
|
export interface FormatterOptions {
|
|
38
41
|
indentationSize?: number;
|
|
39
42
|
pipeOperatorStyle?: FormatterPlacementStyle;
|
|
@@ -112,8 +115,12 @@ declare module monaco.languages.kusto {
|
|
|
112
115
|
* statement.
|
|
113
116
|
* It is also different from getGlobalParams that will return all global parameters whether used or not.
|
|
114
117
|
*/
|
|
115
|
-
getReferencedGlobalParams(uri: string, cursorOffset
|
|
118
|
+
getReferencedGlobalParams(uri: string, cursorOffset?: number): Promise<{ name: string; type: string }[]>;
|
|
116
119
|
|
|
120
|
+
getReferencedSymbols(
|
|
121
|
+
document: TextDocument,
|
|
122
|
+
cursorOffset?: number
|
|
123
|
+
): Promise<{ name: string; kind: string; display: string }[]>;
|
|
117
124
|
/**
|
|
118
125
|
* Get visualization options in render command if present (null otherwise).
|
|
119
126
|
*/
|