@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kusto/monaco-kusto",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.0",
|
|
4
4
|
"description": "CSL, KQL plugin for the Monaco Editor",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Microsoft"
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"xregexp": "^3.2.0"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@kusto/language-service": "0.0.
|
|
58
|
-
"@kusto/language-service-next": "0.0.
|
|
57
|
+
"@kusto/language-service": "0.0.40",
|
|
58
|
+
"@kusto/language-service-next": "0.0.63"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"monaco-editor": "0.34.1"
|
package/release/dev/kustoMode.js
CHANGED
|
@@ -2304,6 +2304,51 @@ var t=_l[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:pop|shift)$/
|
|
|
2304
2304
|
Z.prototype.chain=tf,Z.prototype.commit=rf,Z.prototype.next=ef,Z.prototype.plant=of,Z.prototype.reverse=ff,Z.prototype.toJSON=Z.prototype.valueOf=Z.prototype.value=cf,Z.prototype.first=Z.prototype.head,Ul&&(Z.prototype[Ul]=uf),Z},be=de();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(re._=be,define('lodash/lodash.min',[],function(){return be})):ue?((ue.exports=be)._=be,ee._=be):re._=be}).call(this);
|
|
2305
2305
|
define('lodash', ['lodash/lodash.min'], function (main) { return main; });
|
|
2306
2306
|
|
|
2307
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2308
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
2309
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
2310
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
2311
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
2312
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
2313
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
2314
|
+
});
|
|
2315
|
+
};
|
|
2316
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
2317
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
2318
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
2319
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
2320
|
+
function step(op) {
|
|
2321
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
2322
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
2323
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
2324
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
2325
|
+
switch (op[0]) {
|
|
2326
|
+
case 0: case 1: t = op; break;
|
|
2327
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
2328
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
2329
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
2330
|
+
default:
|
|
2331
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
2332
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
2333
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
2334
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
2335
|
+
if (t[2]) _.ops.pop();
|
|
2336
|
+
_.trys.pop(); continue;
|
|
2337
|
+
}
|
|
2338
|
+
op = body.call(thisArg, _);
|
|
2339
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
2340
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
2341
|
+
}
|
|
2342
|
+
};
|
|
2343
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2344
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
2345
|
+
if (ar || !(i in from)) {
|
|
2346
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
2347
|
+
ar[i] = from[i];
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
2351
|
+
};
|
|
2307
2352
|
define('vs/language/kusto/languageFeatures',["require", "exports", "vscode-languageserver-types", "lodash"], function (require, exports, ls, _) {
|
|
2308
2353
|
"use strict";
|
|
2309
2354
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -2386,6 +2431,26 @@ define('vs/language/kusto/languageFeatures',["require", "exports", "vscode-langu
|
|
|
2386
2431
|
delete _this._debouncedValidations[uriStr];
|
|
2387
2432
|
}
|
|
2388
2433
|
};
|
|
2434
|
+
this._disposables.push(monaco.languages.registerCodeActionProvider(this._languageId, {
|
|
2435
|
+
provideCodeActions: function (model, range, context, _token) { return __awaiter(_this, void 0, void 0, function () {
|
|
2436
|
+
var startOffset, endOffset, showQuickFix, actions;
|
|
2437
|
+
return __generator(this, function (_a) {
|
|
2438
|
+
switch (_a.label) {
|
|
2439
|
+
case 0:
|
|
2440
|
+
startOffset = model.getOffsetAt(range.getStartPosition());
|
|
2441
|
+
endOffset = model.getOffsetAt(range.getEndPosition());
|
|
2442
|
+
showQuickFix = context.markers.length > 0;
|
|
2443
|
+
return [4 /*yield*/, this.getMonacoCodeActions(model, startOffset, endOffset, showQuickFix)];
|
|
2444
|
+
case 1:
|
|
2445
|
+
actions = _a.sent();
|
|
2446
|
+
return [2 /*return*/, {
|
|
2447
|
+
actions: actions,
|
|
2448
|
+
dispose: function () { },
|
|
2449
|
+
}];
|
|
2450
|
+
}
|
|
2451
|
+
});
|
|
2452
|
+
}); },
|
|
2453
|
+
}));
|
|
2389
2454
|
this._disposables.push(this._monacoInstance.editor.onDidCreateEditor(onEditorAdd));
|
|
2390
2455
|
this._disposables.push(this._monacoInstance.editor.onDidCreateModel(onModelAdd));
|
|
2391
2456
|
this._disposables.push(this._monacoInstance.editor.onWillDisposeModel(onModelRemoved));
|
|
@@ -2409,6 +2474,73 @@ define('vs/language/kusto/languageFeatures',["require", "exports", "vscode-langu
|
|
|
2409
2474
|
this._monacoInstance.editor.getModels().forEach(onModelAdd);
|
|
2410
2475
|
this._monacoInstance.editor.getEditors().forEach(onEditorAdd);
|
|
2411
2476
|
}
|
|
2477
|
+
DiagnosticsAdapter.prototype.getMonacoCodeActions = function (model, startOffset, endOffset, enableQuickFix) {
|
|
2478
|
+
var _a;
|
|
2479
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2480
|
+
var actions, worker, resource, codeActions, _loop_1, this_1, i, state_1;
|
|
2481
|
+
return __generator(this, function (_b) {
|
|
2482
|
+
switch (_b.label) {
|
|
2483
|
+
case 0:
|
|
2484
|
+
actions = [];
|
|
2485
|
+
return [4 /*yield*/, this._worker(model.uri)];
|
|
2486
|
+
case 1:
|
|
2487
|
+
worker = _b.sent();
|
|
2488
|
+
resource = model.uri;
|
|
2489
|
+
return [4 /*yield*/, worker.getResultActions(resource.toString(), startOffset, endOffset)];
|
|
2490
|
+
case 2:
|
|
2491
|
+
codeActions = _b.sent();
|
|
2492
|
+
_loop_1 = function (i) {
|
|
2493
|
+
var codeAction = codeActions[i];
|
|
2494
|
+
if (codeAction.title.includes('Extract Function')) {
|
|
2495
|
+
return "continue";
|
|
2496
|
+
}
|
|
2497
|
+
var codeActionKind = ((_a = this_1.defaults.languageSettings.quickFixCodeActions) === null || _a === void 0 ? void 0 : _a.find(function (actionTitle) {
|
|
2498
|
+
return codeAction.title.includes(actionTitle);
|
|
2499
|
+
}))
|
|
2500
|
+
? 'quickfix'
|
|
2501
|
+
: 'custom';
|
|
2502
|
+
if (codeActionKind === 'quickfix' && !enableQuickFix) {
|
|
2503
|
+
return { value: void 0 };
|
|
2504
|
+
}
|
|
2505
|
+
var changes = codeAction.changes;
|
|
2506
|
+
var edits = changes.map(function (change) {
|
|
2507
|
+
var _a;
|
|
2508
|
+
var startPosition = model.getPositionAt(change.start);
|
|
2509
|
+
var endPosition = model.getPositionAt(change.start + change.deleteLength);
|
|
2510
|
+
return {
|
|
2511
|
+
resource: model.uri,
|
|
2512
|
+
textEdit: {
|
|
2513
|
+
range: {
|
|
2514
|
+
startLineNumber: startPosition.lineNumber,
|
|
2515
|
+
startColumn: startPosition.column,
|
|
2516
|
+
endLineNumber: endPosition.lineNumber,
|
|
2517
|
+
endColumn: endPosition.column,
|
|
2518
|
+
},
|
|
2519
|
+
text: (_a = change.insertText) !== null && _a !== void 0 ? _a : '',
|
|
2520
|
+
},
|
|
2521
|
+
};
|
|
2522
|
+
});
|
|
2523
|
+
actions.push({
|
|
2524
|
+
title: codeAction.title,
|
|
2525
|
+
diagnostics: [],
|
|
2526
|
+
kind: codeActionKind,
|
|
2527
|
+
edit: {
|
|
2528
|
+
edits: __spreadArray([], edits, true),
|
|
2529
|
+
},
|
|
2530
|
+
isPreferred: true,
|
|
2531
|
+
});
|
|
2532
|
+
};
|
|
2533
|
+
this_1 = this;
|
|
2534
|
+
for (i = 0; i < codeActions.length; i++) {
|
|
2535
|
+
state_1 = _loop_1(i);
|
|
2536
|
+
if (typeof state_1 === "object")
|
|
2537
|
+
return [2 /*return*/, state_1.value];
|
|
2538
|
+
}
|
|
2539
|
+
return [2 /*return*/, actions];
|
|
2540
|
+
}
|
|
2541
|
+
});
|
|
2542
|
+
});
|
|
2543
|
+
};
|
|
2412
2544
|
DiagnosticsAdapter.prototype.getOrCreateDebouncedValidation = function (model, languageId) {
|
|
2413
2545
|
var _this = this;
|
|
2414
2546
|
var modelUri = model.uri.toString();
|
|
@@ -6672,6 +6672,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
6672
6672
|
};
|
|
6673
6673
|
define('vs/language/kusto/languageService/kustoLanguageService',["require", "exports", "./schema", "vscode-languageserver-types", "xregexp", "./schema"], function (require, exports, s, ls, XRegExp, schema_1) {
|
|
6674
6674
|
"use strict";
|
|
6675
|
+
var _a;
|
|
6675
6676
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6676
6677
|
exports.getKustoLanguageService = exports.TokenKind = void 0;
|
|
6677
6678
|
// polyfill string endsWith
|
|
@@ -6754,6 +6755,30 @@ define('vs/language/kusto/languageService/kustoLanguageService',["require", "exp
|
|
|
6754
6755
|
kind: classification.Kind,
|
|
6755
6756
|
}); });
|
|
6756
6757
|
}
|
|
6758
|
+
var symbolKindToName = (_a = {},
|
|
6759
|
+
_a[sym.SymbolKind.Cluster] = 'Cluster',
|
|
6760
|
+
_a[sym.SymbolKind.Column] = 'Column',
|
|
6761
|
+
_a[sym.SymbolKind.Command] = 'Command',
|
|
6762
|
+
_a[sym.SymbolKind.Database] = 'Database',
|
|
6763
|
+
_a[sym.SymbolKind.EntityGroup] = 'EntityGroup',
|
|
6764
|
+
_a[sym.SymbolKind.EntityGroupElement] = 'EntityGroupElement',
|
|
6765
|
+
_a[sym.SymbolKind.Error] = 'Error',
|
|
6766
|
+
_a[sym.SymbolKind.Function] = 'Function',
|
|
6767
|
+
_a[sym.SymbolKind.Graph] = 'Graph',
|
|
6768
|
+
_a[sym.SymbolKind.Group] = 'Group',
|
|
6769
|
+
_a[sym.SymbolKind.MaterializedView] = 'MaterializedView',
|
|
6770
|
+
_a[sym.SymbolKind.None] = 'None',
|
|
6771
|
+
_a[sym.SymbolKind.Operator] = 'Operator',
|
|
6772
|
+
_a[sym.SymbolKind.Option] = 'Option',
|
|
6773
|
+
_a[sym.SymbolKind.Parameter] = 'Parameter',
|
|
6774
|
+
_a[sym.SymbolKind.Pattern] = 'Pattern',
|
|
6775
|
+
_a[sym.SymbolKind.QueryOperatorParameter] = 'QueryOperatorParameter',
|
|
6776
|
+
_a[sym.SymbolKind.Scalar] = 'Scalar',
|
|
6777
|
+
_a[sym.SymbolKind.Table] = 'Table',
|
|
6778
|
+
_a[sym.SymbolKind.Tuple] = 'Tuple',
|
|
6779
|
+
_a[sym.SymbolKind.Variable] = 'Variable',
|
|
6780
|
+
_a[sym.SymbolKind.Void] = 'Void',
|
|
6781
|
+
_a);
|
|
6757
6782
|
/**
|
|
6758
6783
|
* Kusto Language service translates the kusto object model (transpiled from C# by Bridge.Net)
|
|
6759
6784
|
* to the vscode language server types, which are used by vscode language extensions.
|
|
@@ -7270,6 +7295,53 @@ define('vs/language/kusto/languageService/kustoLanguageService',["require", "exp
|
|
|
7270
7295
|
var lsDiagnostics = this.toLsDiagnostics(diagnostics, document);
|
|
7271
7296
|
return Promise.resolve(lsDiagnostics);
|
|
7272
7297
|
};
|
|
7298
|
+
KustoLanguageService.prototype.getApplyCodeActions = function (document, start, end) {
|
|
7299
|
+
var script = this.parseDocumentV2(document);
|
|
7300
|
+
var block = this.getAffectedBlocks(this.toArray(script.Blocks), [{ start: start, end: end }])[0];
|
|
7301
|
+
var codeActionInfo = block.Service.GetCodeActions(start, start, end - start + 1, null, true, null, new Kusto.Language.Utils.CancellationToken());
|
|
7302
|
+
var codeActions = this.toArray(codeActionInfo.Actions);
|
|
7303
|
+
// Some code actions are of type "MenuAction". We want to flat them out, to show them seperately.
|
|
7304
|
+
var flatCodeActions = [];
|
|
7305
|
+
for (var i = 0; i < codeActions.length; i++) {
|
|
7306
|
+
flatCodeActions.push.apply(flatCodeActions, this.flattenCodeActions(codeActions[i]));
|
|
7307
|
+
}
|
|
7308
|
+
return flatCodeActions;
|
|
7309
|
+
};
|
|
7310
|
+
KustoLanguageService.prototype.getResultActions = function (document, start, end) {
|
|
7311
|
+
var _this = this;
|
|
7312
|
+
var script = this.parseDocumentV2(document);
|
|
7313
|
+
var block = this.getAffectedBlocks(this.toArray(script.Blocks), [{ start: start, end: end }])[0];
|
|
7314
|
+
var applyCodeActions = this.getApplyCodeActions(document, start, end);
|
|
7315
|
+
var resultActionsMap = applyCodeActions
|
|
7316
|
+
.map(function (applyCodeAction) {
|
|
7317
|
+
var changes = [];
|
|
7318
|
+
var codeActionResults = _this.toArray(block.Service.ApplyCodeAction(applyCodeAction, start).Actions);
|
|
7319
|
+
var changeTextAction = codeActionResults.find(function (c) { return c instanceof Kusto.Language.Editor.ChangeTextAction; });
|
|
7320
|
+
if (changeTextAction) {
|
|
7321
|
+
changes = _this.toArray(changeTextAction.Changes).map(function (change) { return ({
|
|
7322
|
+
start: change.Start + block.Start,
|
|
7323
|
+
deleteLength: change.DeleteLength,
|
|
7324
|
+
insertText: change.InsertText,
|
|
7325
|
+
}); });
|
|
7326
|
+
}
|
|
7327
|
+
return { title: applyCodeAction.Title, changes: changes };
|
|
7328
|
+
})
|
|
7329
|
+
.filter(function (resultAction) { return resultAction.changes.length; });
|
|
7330
|
+
return Promise.resolve(resultActionsMap);
|
|
7331
|
+
};
|
|
7332
|
+
KustoLanguageService.prototype.flattenCodeActions = function (codeAction) {
|
|
7333
|
+
var applyActions = [];
|
|
7334
|
+
if (codeAction instanceof k2.ApplyAction) {
|
|
7335
|
+
applyActions.push(codeAction);
|
|
7336
|
+
}
|
|
7337
|
+
else if (codeAction instanceof k2.MenuAction) {
|
|
7338
|
+
var nestedCodeActions = this.toArray(codeAction.Actions);
|
|
7339
|
+
for (var i = 0; i < nestedCodeActions.length; i++) {
|
|
7340
|
+
applyActions.push.apply(applyActions, this.flattenCodeActions(nestedCodeActions[i]));
|
|
7341
|
+
}
|
|
7342
|
+
}
|
|
7343
|
+
return applyActions;
|
|
7344
|
+
};
|
|
7273
7345
|
KustoLanguageService.prototype.toLsDiagnostics = function (diagnostics, document) {
|
|
7274
7346
|
return diagnostics
|
|
7275
7347
|
.filter(function (diag) { return diag.HasLocation; })
|
|
@@ -7863,17 +7935,30 @@ define('vs/language/kusto/languageService/kustoLanguageService',["require", "exp
|
|
|
7863
7935
|
};
|
|
7864
7936
|
return Promise.resolve(renderInfo);
|
|
7865
7937
|
};
|
|
7866
|
-
KustoLanguageService.prototype.
|
|
7867
|
-
|
|
7868
|
-
|
|
7938
|
+
KustoLanguageService.prototype.getReferencedSymbols = function (document, offset) {
|
|
7939
|
+
var parsedAndAnalyzed = this.parseAndAnalyze(document, offset);
|
|
7940
|
+
if (!parsedAndAnalyzed) {
|
|
7941
|
+
Promise.resolve([]);
|
|
7869
7942
|
}
|
|
7870
|
-
|
|
7871
|
-
var
|
|
7872
|
-
|
|
7873
|
-
return
|
|
7943
|
+
// We take all referenced symbols in the query
|
|
7944
|
+
var referencedSymbols = this.toArray(parsedAndAnalyzed.Syntax.GetDescendants(Kusto.Language.Syntax.Expression))
|
|
7945
|
+
.filter(function (expression) { return expression.ReferencedSymbol !== null; })
|
|
7946
|
+
.map(function (x) { return x.ReferencedSymbol; });
|
|
7947
|
+
var result = referencedSymbols.map(function (sym) {
|
|
7948
|
+
var _a;
|
|
7949
|
+
return ({
|
|
7950
|
+
name: sym.Name,
|
|
7951
|
+
kind: (_a = symbolKindToName[sym.Kind]) !== null && _a !== void 0 ? _a : "".concat(sym.Kind),
|
|
7952
|
+
display: sym.Display,
|
|
7953
|
+
});
|
|
7954
|
+
});
|
|
7955
|
+
return Promise.resolve(result);
|
|
7956
|
+
};
|
|
7957
|
+
KustoLanguageService.prototype.getReferencedGlobalParams = function (document, cursorOffset) {
|
|
7958
|
+
var parsedAndAnalyzed = this.parseAndAnalyze(document, cursorOffset);
|
|
7959
|
+
if (!parsedAndAnalyzed) {
|
|
7960
|
+
Promise.resolve([]);
|
|
7874
7961
|
}
|
|
7875
|
-
var text = currentBlock.Text;
|
|
7876
|
-
var parsedAndAnalyzed = Kusto.Language.KustoCode.ParseAndAnalyze(text, this._kustoJsSchemaV2);
|
|
7877
7962
|
// We take the ambient parameters
|
|
7878
7963
|
var ambientParameters = this.toArray(this._kustoJsSchemaV2.Parameters);
|
|
7879
7964
|
// We take all referenced symbols in the query
|
|
@@ -8453,11 +8538,14 @@ define('vs/language/kusto/languageService/kustoLanguageService',["require", "exp
|
|
|
8453
8538
|
return undefined;
|
|
8454
8539
|
}
|
|
8455
8540
|
var script = this.parseDocumentV2(document);
|
|
8456
|
-
var
|
|
8457
|
-
if (
|
|
8458
|
-
|
|
8541
|
+
var text = script.Text;
|
|
8542
|
+
if (cursorOffset !== undefined) {
|
|
8543
|
+
var currentBlock = this.getCurrentCommandV2(script, cursorOffset);
|
|
8544
|
+
if (!currentBlock) {
|
|
8545
|
+
return undefined;
|
|
8546
|
+
}
|
|
8547
|
+
text = currentBlock.Text;
|
|
8459
8548
|
}
|
|
8460
|
-
var text = currentBlock.Text;
|
|
8461
8549
|
var parsedAndAnalyzed = Kusto.Language.KustoCode.ParseAndAnalyze(text, this._kustoJsSchemaV2);
|
|
8462
8550
|
return parsedAndAnalyzed;
|
|
8463
8551
|
};
|
|
@@ -8553,13 +8641,25 @@ define('vs/language/kusto/kustoWorker',["require", "exports", "./languageService
|
|
|
8553
8641
|
}
|
|
8554
8642
|
return globalParams;
|
|
8555
8643
|
};
|
|
8556
|
-
KustoWorker.prototype.
|
|
8644
|
+
KustoWorker.prototype.getReferencedSymbols = function (uri, cursorOffset) {
|
|
8557
8645
|
var document = this._getTextDocument(uri);
|
|
8558
8646
|
if (!document) {
|
|
8559
8647
|
console.error("getReferencedGlobalParams: document is ".concat(document, ". uri is ").concat(uri));
|
|
8560
8648
|
return null;
|
|
8561
8649
|
}
|
|
8562
|
-
var referencedParams = this._languageService.
|
|
8650
|
+
var referencedParams = this._languageService.getReferencedSymbols(document, cursorOffset);
|
|
8651
|
+
if (referencedParams === undefined) {
|
|
8652
|
+
return null;
|
|
8653
|
+
}
|
|
8654
|
+
return referencedParams;
|
|
8655
|
+
};
|
|
8656
|
+
KustoWorker.prototype.getReferencedGlobalParams = function (uri, cursorOffset) {
|
|
8657
|
+
var document = this._getTextDocument(uri);
|
|
8658
|
+
if (!document) {
|
|
8659
|
+
console.error("getReferencedGlobalParams: document is ".concat(document, ". uri is ").concat(uri));
|
|
8660
|
+
return null;
|
|
8661
|
+
}
|
|
8662
|
+
var referencedParams = this._languageService.getReferencedGlobalParams(document, cursorOffset);
|
|
8563
8663
|
if (referencedParams === undefined) {
|
|
8564
8664
|
return null;
|
|
8565
8665
|
}
|
|
@@ -8623,6 +8723,10 @@ define('vs/language/kusto/kustoWorker',["require", "exports", "./languageService
|
|
|
8623
8723
|
var diagnostics = this._languageService.doValidation(document, intervals, includeWarnings, includeSuggestions);
|
|
8624
8724
|
return diagnostics;
|
|
8625
8725
|
};
|
|
8726
|
+
KustoWorker.prototype.getResultActions = function (uri, start, end) {
|
|
8727
|
+
var document = this._getTextDocument(uri);
|
|
8728
|
+
return this._languageService.getResultActions(document, start, end);
|
|
8729
|
+
};
|
|
8626
8730
|
KustoWorker.prototype.doRangeFormat = function (uri, range) {
|
|
8627
8731
|
var document = this._getTextDocument(uri);
|
|
8628
8732
|
var formatted = this._languageService.doRangeFormat(document, range);
|
|
@@ -205,6 +205,7 @@ define('vs/language/kusto/monaco.contribution',["require", "exports", "./command
|
|
|
205
205
|
enableQueryWarnings: false,
|
|
206
206
|
enableQuerySuggestions: false,
|
|
207
207
|
disabledDiagnosticCodes: [],
|
|
208
|
+
quickFixCodeActions: ['Change to'],
|
|
208
209
|
};
|
|
209
210
|
function getKustoWorker() {
|
|
210
211
|
return new Promise(function (resolve, reject) {
|
|
@@ -72,13 +72,25 @@ var KustoWorker = /** @class */ (function () {
|
|
|
72
72
|
}
|
|
73
73
|
return globalParams;
|
|
74
74
|
};
|
|
75
|
-
KustoWorker.prototype.
|
|
75
|
+
KustoWorker.prototype.getReferencedSymbols = function (uri, cursorOffset) {
|
|
76
76
|
var document = this._getTextDocument(uri);
|
|
77
77
|
if (!document) {
|
|
78
78
|
console.error("getReferencedGlobalParams: document is ".concat(document, ". uri is ").concat(uri));
|
|
79
79
|
return null;
|
|
80
80
|
}
|
|
81
|
-
var referencedParams = this._languageService.
|
|
81
|
+
var referencedParams = this._languageService.getReferencedSymbols(document, cursorOffset);
|
|
82
|
+
if (referencedParams === undefined) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
return referencedParams;
|
|
86
|
+
};
|
|
87
|
+
KustoWorker.prototype.getReferencedGlobalParams = function (uri, cursorOffset) {
|
|
88
|
+
var document = this._getTextDocument(uri);
|
|
89
|
+
if (!document) {
|
|
90
|
+
console.error("getReferencedGlobalParams: document is ".concat(document, ". uri is ").concat(uri));
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
var referencedParams = this._languageService.getReferencedGlobalParams(document, cursorOffset);
|
|
82
94
|
if (referencedParams === undefined) {
|
|
83
95
|
return null;
|
|
84
96
|
}
|
|
@@ -142,6 +154,10 @@ var KustoWorker = /** @class */ (function () {
|
|
|
142
154
|
var diagnostics = this._languageService.doValidation(document, intervals, includeWarnings, includeSuggestions);
|
|
143
155
|
return diagnostics;
|
|
144
156
|
};
|
|
157
|
+
KustoWorker.prototype.getResultActions = function (uri, start, end) {
|
|
158
|
+
var document = this._getTextDocument(uri);
|
|
159
|
+
return this._languageService.getResultActions(document, start, end);
|
|
160
|
+
};
|
|
145
161
|
KustoWorker.prototype.doRangeFormat = function (uri, range) {
|
|
146
162
|
var document = this._getTextDocument(uri);
|
|
147
163
|
var formatted = this._languageService.doRangeFormat(document, range);
|
|
@@ -1,3 +1,48 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
38
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
39
|
+
if (ar || !(i in from)) {
|
|
40
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
41
|
+
ar[i] = from[i];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
45
|
+
};
|
|
1
46
|
import * as ls from './_deps/vscode-languageserver-types/main';
|
|
2
47
|
import * as _ from './_deps/lodash/lodash';
|
|
3
48
|
var Uri = monaco.Uri;
|
|
@@ -78,6 +123,26 @@ var DiagnosticsAdapter = /** @class */ (function () {
|
|
|
78
123
|
delete _this._debouncedValidations[uriStr];
|
|
79
124
|
}
|
|
80
125
|
};
|
|
126
|
+
this._disposables.push(monaco.languages.registerCodeActionProvider(this._languageId, {
|
|
127
|
+
provideCodeActions: function (model, range, context, _token) { return __awaiter(_this, void 0, void 0, function () {
|
|
128
|
+
var startOffset, endOffset, showQuickFix, actions;
|
|
129
|
+
return __generator(this, function (_a) {
|
|
130
|
+
switch (_a.label) {
|
|
131
|
+
case 0:
|
|
132
|
+
startOffset = model.getOffsetAt(range.getStartPosition());
|
|
133
|
+
endOffset = model.getOffsetAt(range.getEndPosition());
|
|
134
|
+
showQuickFix = context.markers.length > 0;
|
|
135
|
+
return [4 /*yield*/, this.getMonacoCodeActions(model, startOffset, endOffset, showQuickFix)];
|
|
136
|
+
case 1:
|
|
137
|
+
actions = _a.sent();
|
|
138
|
+
return [2 /*return*/, {
|
|
139
|
+
actions: actions,
|
|
140
|
+
dispose: function () { },
|
|
141
|
+
}];
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}); },
|
|
145
|
+
}));
|
|
81
146
|
this._disposables.push(this._monacoInstance.editor.onDidCreateEditor(onEditorAdd));
|
|
82
147
|
this._disposables.push(this._monacoInstance.editor.onDidCreateModel(onModelAdd));
|
|
83
148
|
this._disposables.push(this._monacoInstance.editor.onWillDisposeModel(onModelRemoved));
|
|
@@ -101,6 +166,73 @@ var DiagnosticsAdapter = /** @class */ (function () {
|
|
|
101
166
|
this._monacoInstance.editor.getModels().forEach(onModelAdd);
|
|
102
167
|
this._monacoInstance.editor.getEditors().forEach(onEditorAdd);
|
|
103
168
|
}
|
|
169
|
+
DiagnosticsAdapter.prototype.getMonacoCodeActions = function (model, startOffset, endOffset, enableQuickFix) {
|
|
170
|
+
var _a;
|
|
171
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
172
|
+
var actions, worker, resource, codeActions, _loop_1, this_1, i, state_1;
|
|
173
|
+
return __generator(this, function (_b) {
|
|
174
|
+
switch (_b.label) {
|
|
175
|
+
case 0:
|
|
176
|
+
actions = [];
|
|
177
|
+
return [4 /*yield*/, this._worker(model.uri)];
|
|
178
|
+
case 1:
|
|
179
|
+
worker = _b.sent();
|
|
180
|
+
resource = model.uri;
|
|
181
|
+
return [4 /*yield*/, worker.getResultActions(resource.toString(), startOffset, endOffset)];
|
|
182
|
+
case 2:
|
|
183
|
+
codeActions = _b.sent();
|
|
184
|
+
_loop_1 = function (i) {
|
|
185
|
+
var codeAction = codeActions[i];
|
|
186
|
+
if (codeAction.title.includes('Extract Function')) {
|
|
187
|
+
return "continue";
|
|
188
|
+
}
|
|
189
|
+
var codeActionKind = ((_a = this_1.defaults.languageSettings.quickFixCodeActions) === null || _a === void 0 ? void 0 : _a.find(function (actionTitle) {
|
|
190
|
+
return codeAction.title.includes(actionTitle);
|
|
191
|
+
}))
|
|
192
|
+
? 'quickfix'
|
|
193
|
+
: 'custom';
|
|
194
|
+
if (codeActionKind === 'quickfix' && !enableQuickFix) {
|
|
195
|
+
return { value: void 0 };
|
|
196
|
+
}
|
|
197
|
+
var changes = codeAction.changes;
|
|
198
|
+
var edits = changes.map(function (change) {
|
|
199
|
+
var _a;
|
|
200
|
+
var startPosition = model.getPositionAt(change.start);
|
|
201
|
+
var endPosition = model.getPositionAt(change.start + change.deleteLength);
|
|
202
|
+
return {
|
|
203
|
+
resource: model.uri,
|
|
204
|
+
textEdit: {
|
|
205
|
+
range: {
|
|
206
|
+
startLineNumber: startPosition.lineNumber,
|
|
207
|
+
startColumn: startPosition.column,
|
|
208
|
+
endLineNumber: endPosition.lineNumber,
|
|
209
|
+
endColumn: endPosition.column,
|
|
210
|
+
},
|
|
211
|
+
text: (_a = change.insertText) !== null && _a !== void 0 ? _a : '',
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
});
|
|
215
|
+
actions.push({
|
|
216
|
+
title: codeAction.title,
|
|
217
|
+
diagnostics: [],
|
|
218
|
+
kind: codeActionKind,
|
|
219
|
+
edit: {
|
|
220
|
+
edits: __spreadArray([], edits, true),
|
|
221
|
+
},
|
|
222
|
+
isPreferred: true,
|
|
223
|
+
});
|
|
224
|
+
};
|
|
225
|
+
this_1 = this;
|
|
226
|
+
for (i = 0; i < codeActions.length; i++) {
|
|
227
|
+
state_1 = _loop_1(i);
|
|
228
|
+
if (typeof state_1 === "object")
|
|
229
|
+
return [2 /*return*/, state_1.value];
|
|
230
|
+
}
|
|
231
|
+
return [2 /*return*/, actions];
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
};
|
|
104
236
|
DiagnosticsAdapter.prototype.getOrCreateDebouncedValidation = function (model, languageId) {
|
|
105
237
|
var _this = this;
|
|
106
238
|
var modelUri = model.uri.toString();
|