@kusto/monaco-kusto 11.4.0 → 12.0.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.
Files changed (44) hide show
  1. package/README.md +19 -1
  2. package/package.json +3 -1
  3. package/release/dev/globals-0aacfe72.js +46 -0
  4. package/release/dev/kustoMode.js +214 -497
  5. package/release/dev/kustoWorker.js +49 -90
  6. package/release/dev/{main-1587ba64.js → main-b690e47e.js} +2 -2
  7. package/release/dev/monaco.contribution.js +235 -201
  8. package/release/dev/{schema-a5230652.js → schema-957f5e9b.js} +13 -2
  9. package/release/esm/extendedGlobalApi/getRangeHtml.d.ts +2 -0
  10. package/release/esm/extendedGlobalApi/getRangeHtml.js +11 -0
  11. package/release/esm/extendedGlobalApi/index.d.ts +1 -0
  12. package/release/esm/extendedGlobalApi/index.js +1 -0
  13. package/release/esm/globals-88d92b64.js +40 -0
  14. package/release/esm/globals.d.ts +1 -0
  15. package/release/esm/globals.js +1 -0
  16. package/release/esm/kusto.worker.js +39 -91
  17. package/release/esm/kustoMode.js +39 -29
  18. package/release/esm/kustoWorker.d.ts +2 -5
  19. package/release/esm/kustoWorker.js +2 -5
  20. package/release/esm/languageFeatures.d.ts +0 -13
  21. package/release/esm/languageFeatures.js +0 -299
  22. package/release/esm/languageServiceManager/kustoLanguageService.d.ts +2 -4
  23. package/release/esm/languageServiceManager/kustoLanguageService.js +58 -71
  24. package/release/esm/languageServiceManager/settings.d.ts +0 -2
  25. package/release/esm/monaco.contribution.d.ts +1 -6
  26. package/release/esm/monaco.contribution.js +22 -79
  27. package/release/esm/{schema-c006895b.js → schema-66580db4.js} +12 -2
  28. package/release/esm/syntaxHighlighting/SemanticTokensProvider.d.ts +18 -0
  29. package/release/esm/syntaxHighlighting/SemanticTokensProvider.js +78 -0
  30. package/release/esm/syntaxHighlighting/kustoMonarchLanguageDefinition.d.ts +2 -0
  31. package/release/esm/syntaxHighlighting/kustoMonarchLanguageDefinition.js +401 -0
  32. package/release/esm/syntaxHighlighting/themes.d.ts +11 -0
  33. package/release/esm/syntaxHighlighting/themes.js +103 -0
  34. package/release/esm/syntaxHighlighting/types.d.ts +41 -0
  35. package/release/esm/syntaxHighlighting/types.js +55 -0
  36. package/release/min/globals-cce7b304.js +7 -0
  37. package/release/min/kustoMode.js +2 -2
  38. package/release/min/kustoWorker.js +4 -4
  39. package/release/min/{main-75aa3e71.js → main-13659fc4.js} +2 -2
  40. package/release/min/monaco.contribution.js +2 -2
  41. package/release/min/schema-ab3cbb28.js +7 -0
  42. package/release/esm/languageServiceManager/kustoMonarchLanguageDefinition.d.ts +0 -2
  43. package/release/esm/languageServiceManager/kustoMonarchLanguageDefinition.js +0 -211
  44. package/release/min/schema-192b3175.js +0 -7
@@ -362,305 +362,6 @@ function toDiagnostics(resource, diag) {
362
362
  source: diag.source,
363
363
  };
364
364
  }
365
- /**
366
- * Copy of Kusto.Language.Editor.ClassificationKind we don't have to depend on it in this file
367
- */
368
- var ClassificationKind = {
369
- PlainText: 0,
370
- Comment: 1,
371
- Punctuation: 2,
372
- Directive: 3,
373
- Literal: 4,
374
- StringLiteral: 5,
375
- Type: 6,
376
- Column: 7,
377
- Table: 8,
378
- Database: 9,
379
- Function: 10,
380
- Parameter: 11,
381
- Variable: 12,
382
- Identifier: 13,
383
- ClientParameter: 14,
384
- QueryParameter: 15,
385
- ScalarOperator: 16,
386
- MathOperator: 17,
387
- QueryOperator: 18,
388
- Command: 19,
389
- Keyword: 20,
390
- MaterializedView: 21,
391
- SchemaMember: 22,
392
- SignatureParameter: 23,
393
- Option: 24,
394
- };
395
- var ClassificationKindNames = {};
396
- for (var _i = 0, _a = Object.entries(ClassificationKind); _i < _a.length; _i++) {
397
- var _b = _a[_i], key = _b[0], value = _b[1];
398
- ClassificationKindNames[value] = key;
399
- }
400
- // commented here is the color definitions are were defined by v1 intellisense terminology:
401
- // { token: 'comment', foreground: '008000' }, // CommentToken Green
402
- // { token: 'variable.predefined', foreground: '800080' }, // CalculatedColumnToken Purple
403
- // { token: 'function', foreground: '0000FF' }, // FunctionNameToken Blue
404
- // { token: 'operator.sql', foreground: 'FF4500' }, // OperatorToken OrangeRed (now changed to darker color CC3700 because wasn't accessible)
405
- // { token: 'string', foreground: 'B22222' }, // StringLiteralToken Firebrick
406
- // { token: 'operator.scss', foreground: '0000FF' }, // SubOperatorToken Blue
407
- // { token: 'variable', foreground: 'C71585' }, // TableColumnToken MediumVioletRed
408
- // { token: 'variable.parameter', foreground: '9932CC' }, // TableToken DarkOrchid
409
- // { token: '', foreground: '000000' }, // UnknownToken, PlainTextToken Black
410
- // { token: 'type', foreground: '0000FF' }, // DataTypeToken Blue
411
- // { token: 'tag', foreground: '0000FF' }, // ControlCommandToken Blue
412
- // { token: 'annotation', foreground: '2B91AF' }, // QueryParametersToken FF2B91AF
413
- // { token: 'keyword', foreground: '0000FF' }, // CslCommandToken, PluginToken Blue
414
- // { token: 'number', foreground: '191970' }, // LetVariablesToken MidnightBlue
415
- // { token: 'annotation', foreground: '9400D3' }, // ClientDirectiveToken DarkViolet
416
- // { token: 'invalid', background: 'cd3131' },
417
- var classificationToColorLight = {
418
- Column: 'C71585',
419
- Comment: '008000',
420
- Database: 'C71585',
421
- Function: '0000FF',
422
- Identifier: '000000',
423
- Keyword: '0000FF',
424
- Literal: 'B22222',
425
- ScalarOperator: '0000FF',
426
- MaterializedView: 'C71585',
427
- MathOperator: '000000',
428
- Command: '0000FF',
429
- Parameter: '2B91AF',
430
- PlainText: '000000',
431
- Punctuation: '000000',
432
- QueryOperator: 'CC3700',
433
- QueryParameter: 'CC3700',
434
- StringLiteral: 'B22222',
435
- Table: 'C71585',
436
- Type: '0000FF',
437
- Variable: '191970',
438
- Directive: '9400D3',
439
- ClientParameter: 'b5cea8',
440
- SchemaMember: 'C71585',
441
- SignatureParameter: '2B91AF',
442
- Option: '000000',
443
- };
444
- var classificationToColorDark = {
445
- Column: '4ec9b0',
446
- Comment: '6A9B34',
447
- Database: 'c586c0',
448
- Function: 'dcdcaa',
449
- Identifier: 'd4d4d4',
450
- Keyword: '569cd6',
451
- Literal: 'ce9178',
452
- ScalarOperator: '569cd6',
453
- MaterializedView: 'c586c0',
454
- MathOperator: 'd4d4d4',
455
- Command: 'd4d4d4',
456
- Parameter: '2B91AF',
457
- PlainText: 'd4d4d4',
458
- Punctuation: 'd4d4d4',
459
- QueryOperator: '9cdcfe',
460
- QueryParameter: '9cdcfe',
461
- StringLiteral: 'ce9178',
462
- Table: 'c586c0',
463
- Type: '569cd6',
464
- Variable: 'd7ba7d',
465
- Directive: 'b5cea8',
466
- ClientParameter: 'b5cea8',
467
- SchemaMember: '4ec9b0',
468
- SignatureParameter: '2B91AF',
469
- Option: 'd4d4d4',
470
- };
471
- var ColorizationAdapter = /** @class */ (function () {
472
- function ColorizationAdapter(_monacoInstance, _languageId, _worker, defaults, onSchemaChange) {
473
- var _this = this;
474
- this._monacoInstance = _monacoInstance;
475
- this._languageId = _languageId;
476
- this._worker = _worker;
477
- this._disposables = [];
478
- this._contentListener = Object.create(null);
479
- this._configurationListener = Object.create(null);
480
- this._schemaListener = Object.create(null);
481
- this.decorations = [];
482
- injectCss();
483
- var onModelAdd = function (model) {
484
- var languageId = model.getLanguageId();
485
- if (languageId !== _this._languageId) {
486
- return;
487
- }
488
- var debouncedColorization = debounce(function (intervals) { return _this._doColorization(model, languageId, intervals); }, 500);
489
- var handle;
490
- _this._contentListener[model.uri.toString()] = model.onDidChangeContent(function (e) {
491
- // Changes are represented as a range in doc before change, plus the text that it was replaced with.
492
- // We are interested in the range _after_ the change (since that's what we need to colorize).
493
- // following logic calculates that.
494
- var intervalsToColorize = changeEventToIntervals(e);
495
- debouncedColorization(intervalsToColorize);
496
- });
497
- _this._configurationListener[model.uri.toString()] = defaults.onDidChange(function () {
498
- self.setTimeout(function () { return _this._doColorization(model, languageId, []); }, 0);
499
- });
500
- _this._schemaListener[model.uri.toString()] = onSchemaChange(function () {
501
- self.setTimeout(function () { return _this._doColorization(model, languageId, []); }, 0);
502
- });
503
- };
504
- var onModelRemoved = function (model) {
505
- model.deltaDecorations(_this.decorations, []);
506
- var uriStr = model.uri.toString();
507
- var contentListener = _this._contentListener[uriStr];
508
- if (contentListener) {
509
- contentListener.dispose();
510
- delete _this._contentListener[uriStr];
511
- }
512
- var configurationListener = _this._configurationListener[uriStr];
513
- if (configurationListener) {
514
- configurationListener.dispose();
515
- delete _this._configurationListener[uriStr];
516
- }
517
- var schemaListener = _this._configurationListener[uriStr];
518
- if (schemaListener) {
519
- schemaListener.dispose();
520
- delete _this._schemaListener[uriStr];
521
- }
522
- };
523
- this._disposables.push(this._monacoInstance.editor.onDidCreateModel(onModelAdd));
524
- this._disposables.push(this._monacoInstance.editor.onWillDisposeModel(onModelRemoved));
525
- this._disposables.push(this._monacoInstance.editor.onDidChangeModelLanguage(function (event) {
526
- onModelRemoved(event.model);
527
- onModelAdd(event.model);
528
- }));
529
- this._disposables.push({
530
- dispose: function () {
531
- for (var key in _this._contentListener) {
532
- _this._contentListener[key].dispose();
533
- }
534
- },
535
- });
536
- this._monacoInstance.editor.getModels().forEach(onModelAdd);
537
- }
538
- ColorizationAdapter.prototype.dispose = function () {
539
- this._disposables.forEach(function (d) { return d && d.dispose(); });
540
- this._disposables = [];
541
- };
542
- ColorizationAdapter.prototype._doColorization = function (model, languageId, intervals) {
543
- var _this = this;
544
- if (model.isDisposed()) {
545
- return;
546
- }
547
- var resource = model.uri;
548
- var versionNumberBeforeColorization = model.getVersionId();
549
- this._worker(resource)
550
- .then(function (worker) {
551
- if (model.isDisposed()) {
552
- return;
553
- }
554
- return worker.doColorization(resource.toString(), intervals);
555
- })
556
- .then(function (colorizationRanges) {
557
- if (model.isDisposed()) {
558
- return;
559
- }
560
- var newModel = _this._monacoInstance.editor.getModel(model.uri);
561
- var versionId = newModel.getVersionId();
562
- // don't colorize an older version of the document.
563
- if (versionId !== versionNumberBeforeColorization) {
564
- return;
565
- }
566
- var decorationRanges = colorizationRanges.map(function (colorizationRange) {
567
- var decorations = colorizationRange.classifications
568
- .map(function (classification) { return toDecoration(model, classification); })
569
- // The following line will prevent things that aren't going to be colorized anyway to get a CSS class.
570
- // This will prevent the case where the non-semantic colorizer already figured out that a keyword needs
571
- // to be colorized, but the outdated semantic colorizer still thinks it's a plain text and wants it colored
572
- // in black.
573
- .filter(function (d) {
574
- return d.options.inlineClassName !== 'PlainText' && d.options.inlineClassName != 'Identifier';
575
- });
576
- var firstImpactedLine = model.getPositionAt(colorizationRange.absoluteStart).lineNumber;
577
- var endPosition = model.getPositionAt(colorizationRange.absoluteEnd);
578
- // A token that ends in the first column of the next line is not considered to be part of that line.
579
- var lastImpactedLine = endPosition.column == 1 && endPosition.lineNumber > 1
580
- ? endPosition.lineNumber - 1
581
- : endPosition.lineNumber;
582
- return { decorations: decorations, firstImpactedLine: firstImpactedLine, lastImpactedLine: lastImpactedLine };
583
- });
584
- // Compute the previous decorations we want to replace with the new ones.
585
- var oldDecorations = decorationRanges
586
- .map(function (range) {
587
- return model
588
- .getLinesDecorations(range.firstImpactedLine, range.lastImpactedLine)
589
- .filter(function (d) { return classificationToColorLight[d.options.inlineClassName]; }) // Don't delete any other decorations
590
- .map(function (d) { return d.id; });
591
- })
592
- .reduce(function (prev, curr) { return prev.concat(curr); }, []);
593
- // Flatten decoration groups to an array of decorations
594
- var newDecorations = decorationRanges.reduce(function (prev, next) { return prev.concat(next.decorations); }, []);
595
- if (model && model.getLanguageId() === languageId) {
596
- _this.decorations = model.deltaDecorations(oldDecorations, newDecorations);
597
- }
598
- })
599
- .catch(function (err) {
600
- // Hack to avoid crashing calling code, while still logging the
601
- // error. Might be better to just let the error propagate
602
- // normally, but that would require more investigation.
603
- setTimeout(function () {
604
- throw err;
605
- }, 0);
606
- });
607
- };
608
- return ColorizationAdapter;
609
- }());
610
- export { ColorizationAdapter };
611
- /**
612
- * Generates a mapping between ClassificationKind and color.
613
- */
614
- function getClassificationColorTriplets() {
615
- var result = Object.keys(ClassificationKind).map(function (key) { return ({
616
- classification: key,
617
- colorLight: classificationToColorLight[key],
618
- colorDark: classificationToColorDark[key],
619
- }); });
620
- return result;
621
- }
622
- /**
623
- * Returns a string which is a css describing all tokens and their colors.
624
- * looks a little bit something like this:
625
- *
626
- * .vs .Literal {color: '#000000';} .vs-dark .Literal {color: '#FFFFFF';}
627
- * .vs .Comment {color: '#111111';} .vs-dark .Comment {color: '#EEEEEE';}
628
- */
629
- function getCssForClassification() {
630
- var classificationColorTriplets = getClassificationColorTriplets();
631
- var cssInnerHtml = classificationColorTriplets
632
- .map(function (pair) {
633
- return ".vs .".concat(pair.classification, " {color: #").concat(pair.colorLight, ";} .vs-dark .").concat(pair.classification, " {color: #").concat(pair.colorDark, ";}");
634
- })
635
- .join('\n');
636
- return cssInnerHtml;
637
- }
638
- /**
639
- * Inject a CSS sheet to the head of document, coloring kusto elements by classification.
640
- * TODO: make idempotent
641
- */
642
- function injectCss() {
643
- var container = document.getElementsByTagName('head')[0];
644
- var style = document.createElement('style');
645
- style.type = 'text/css';
646
- style.media = 'screen';
647
- container.appendChild(style);
648
- ClassificationKind;
649
- style.innerHTML = getCssForClassification();
650
- }
651
- function toDecoration(model, classification) {
652
- var start = model.getPositionAt(classification.start);
653
- var end = model.getPositionAt(classification.start + classification.length);
654
- var range = new monaco.Range(start.lineNumber, start.column, end.lineNumber, end.column);
655
- var inlineClassName = ClassificationKindNames[classification.kind];
656
- return {
657
- range: range,
658
- options: {
659
- inlineClassName: inlineClassName,
660
- stickiness: monaco.editor.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
661
- },
662
- };
663
- }
664
365
  // --- completion ------
665
366
  function fromPosition(position) {
666
367
  if (!position) {
@@ -11,6 +11,7 @@ import k2 = Kusto.Language.Editor;
11
11
  import { Database } from './schema';
12
12
  import type { RenderInfo } from './renderInfo';
13
13
  import type { ClusterReference, DatabaseReference } from '../types';
14
+ import { ClassificationRange } from '../syntaxHighlighting/types';
14
15
  export declare enum TokenKind {
15
16
  TableToken = 2,
16
17
  TableColumnToken = 4,
@@ -72,10 +73,7 @@ export interface LanguageService {
72
73
  end: number;
73
74
  }[], includeWarnings?: boolean, includeSuggestions?: boolean): Promise<ls.Diagnostic[]>;
74
75
  getResultActions(document: TextDocument, start: number, end: number): Promise<ResultAction[]>;
75
- doColorization(document: TextDocument, intervals: {
76
- start: number;
77
- end: number;
78
- }[]): Promise<ColorizationRange[]>;
76
+ getClassifications(document: TextDocument): Promise<ClassificationRange[]>;
79
77
  doRename(document: TextDocument, position: ls.Position, newName: string): Promise<ls.WorkspaceEdit | undefined>;
80
78
  doHover(document: TextDocument, position: ls.Position): Promise<ls.Hover | undefined>;
81
79
  setParameters(scalarParameters: readonly s.ScalarParameter[], tabularParameters: readonly s.TabularParameter[]): Promise<void>;
@@ -9,6 +9,42 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ 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;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
12
48
  var __rest = (this && this.__rest) || function (s, e) {
13
49
  var t = {};
14
50
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -86,18 +122,6 @@ export var TokenKind;
86
122
  TokenKind[TokenKind["BracketRangeToken"] = 262144] = "BracketRangeToken";
87
123
  TokenKind[TokenKind["ClientDirectiveToken"] = 524288] = "ClientDirectiveToken";
88
124
  })(TokenKind || (TokenKind = {}));
89
- /**
90
- * convert the bridge.net object to a plain javascript object that only contains data.
91
- * @param k2Classifications @kusto/language-service-next bridge.net object
92
- */
93
- function toClassifiedRange(k2Classifications) {
94
- return k2Classifications.map(function (classification) { return ({
95
- start: classification.Start,
96
- end: classification.End,
97
- length: classification.Length,
98
- kind: classification.Kind,
99
- }); });
100
- }
101
125
  var symbolKindToName = (_a = {},
102
126
  _a[sym.SymbolKind.Cluster] = 'Cluster',
103
127
  _a[sym.SymbolKind.Column] = 'Column',
@@ -182,22 +206,6 @@ var KustoLanguageService = /** @class */ (function () {
182
206
  '3Dchart': k2.CompletionKind.RenderChart,
183
207
  list: k2.CompletionKind.RenderChart,
184
208
  };
185
- this.disabledCompletionItemsV1 = {
186
- capacity: k.OptionKind.Policy,
187
- callout: k.OptionKind.Policy,
188
- encoding: k.OptionKind.Policy,
189
- batching: k.OptionKind.Policy,
190
- querythrottling: k.OptionKind.Policy,
191
- merge: k.OptionKind.Policy,
192
- querylimit: k.OptionKind.Policy,
193
- rowstore: k.OptionKind.Policy,
194
- streamingingestion: k.OptionKind.Policy,
195
- restricted_view_access: k.OptionKind.Policy,
196
- sharding: k.OptionKind.Policy,
197
- 'restricted-viewers': k.OptionKind.Policy,
198
- attach: k.OptionKind.Command,
199
- purge: k.OptionKind.Command,
200
- };
201
209
  this._kustoKindtolsKind = (_b = {},
202
210
  _b[k.OptionKind.None] = ls.CompletionItemKind.Interface,
203
211
  _b[k.OptionKind.Operator] = ls.CompletionItemKind.Method,
@@ -675,46 +683,27 @@ var KustoLanguageService = /** @class */ (function () {
675
683
  return ls.Diagnostic.create(range, diag.Message, severity, diag.Code);
676
684
  });
677
685
  };
678
- /**
679
- * Colorize one or more kusto blocks (a.k.a commands), or just the entire document.
680
- * Supports multi-cursor editing (colorizes blocks on multiple changes).
681
- * @param document The document to colorize
682
- * @param changeIntervals an array containing 0 or more changed intervals. if the array is empty - just colorize the entire row.
683
- * if the array contains a single change - just color the kusto blocks that wraps this change. If multiple changes are provided,
684
- * colorize all blocks that intersect these changes.
685
- * The code will try to only parse once if this is the same command.
686
- */
687
- KustoLanguageService.prototype.doColorization = function (document, changeIntervals) {
688
- var _this = this;
689
- if (!document || !this._languageSettings.useSemanticColorization) {
690
- return Promise.resolve([]);
691
- }
692
- // V2 intellisense
693
- var script = this.parseDocumentV2(document);
694
- if (changeIntervals.length > 0) {
695
- var blocks_1 = this.toArray(script.Blocks);
696
- var affectedBlocks = this.getAffectedBlocks(blocks_1, changeIntervals);
697
- var result = affectedBlocks.map(function (block) { return ({
698
- classifications: toClassifiedRange(_this.toArray(block.Service.GetClassifications(block.Start, block.End).Classifications)),
699
- absoluteStart: block.Start,
700
- absoluteEnd: block.End,
701
- }); });
702
- return Promise.resolve(result);
703
- }
704
- // Entire document requested
705
- var blocks = this.toArray(script.Blocks);
706
- var classifications = blocks
707
- .map(function (block) {
708
- return _this.toArray(block.Service.GetClassifications(block.Start, block.Length).Classifications);
709
- })
710
- .reduce(function (prev, curr) { return prev.concat(curr); }, []);
711
- return Promise.resolve([
712
- {
713
- classifications: toClassifiedRange(classifications),
714
- absoluteStart: 0,
715
- absoluteEnd: document.getText().length,
716
- },
717
- ]);
686
+ KustoLanguageService.prototype.getClassifications = function (document) {
687
+ return __awaiter(this, void 0, void 0, function () {
688
+ var codeScript, codeBlocks, classificationRanges;
689
+ var _this = this;
690
+ return __generator(this, function (_a) {
691
+ codeScript = this.parseDocumentV2(document);
692
+ codeBlocks = this.toArray(codeScript.Blocks);
693
+ classificationRanges = codeBlocks.map(function (block) {
694
+ var Classifications = block.Service.GetClassifications(block.Start, block.Length).Classifications;
695
+ return _this.toArray(Classifications);
696
+ });
697
+ return [2 /*return*/, classificationRanges.flatMap(function (ranges) {
698
+ return ranges.map(function (range) {
699
+ var _a = document.positionAt(range.Start), line = _a.line, character = _a.character;
700
+ var length = range.Length;
701
+ var kind = range.Kind;
702
+ return { line: line, character: character, length: length, kind: kind };
703
+ });
704
+ })];
705
+ });
706
+ });
718
707
  };
719
708
  KustoLanguageService.prototype.getAffectedBlocks = function (blocks, changeIntervals) {
720
709
  return blocks.filter(function (block) {
@@ -1612,8 +1601,7 @@ var KustoLanguageService = /** @class */ (function () {
1612
1601
  return command;
1613
1602
  };
1614
1603
  KustoLanguageService.prototype.getCurrentCommandV2 = function (script, offset) {
1615
- var block = script.GetBlockAtPosition(offset);
1616
- return block;
1604
+ return script.GetBlockAtPosition(offset);
1617
1605
  };
1618
1606
  KustoLanguageService.prototype.getTextToInsert = function (rule, option) {
1619
1607
  var beforeApplyInfo = rule.GetBeforeApplyInfo(option.Value);
@@ -1744,7 +1732,6 @@ var KustoLanguageService = /** @class */ (function () {
1744
1732
  }());
1745
1733
  var languageService = new KustoLanguageService(KustoLanguageService.dummySchema, {
1746
1734
  includeControlCommands: true,
1747
- useSemanticColorization: true,
1748
1735
  completionOptions: { includeExtendedSyntax: false },
1749
1736
  });
1750
1737
  /**
@@ -3,8 +3,6 @@ export interface LanguageSettings {
3
3
  includeControlCommands?: boolean;
4
4
  newlineAfterPipe?: boolean;
5
5
  openSuggestionDialogAfterPreviousSuggestionAccepted?: boolean;
6
- useSemanticColorization?: boolean;
7
- useTokenColorization?: boolean;
8
6
  disabledCompletionItems?: string[];
9
7
  onDidProvideCompletionItems?: OnDidProvideCompletionItems;
10
8
  enableHover?: boolean;
@@ -5,7 +5,7 @@ export * from './languageServiceManager/schema';
5
5
  export * from './languageServiceManager/renderInfo';
6
6
  export * from './languageServiceManager/settings';
7
7
  export * from './types';
8
- export { getCurrentCommandRange } from './extendedEditor';
8
+ export * from './extendedGlobalApi';
9
9
  declare class LanguageServiceDefaultsImpl implements LanguageServiceDefaults {
10
10
  private _onDidChange;
11
11
  private _languageSettings;
@@ -19,8 +19,3 @@ declare class LanguageServiceDefaultsImpl implements LanguageServiceDefaults {
19
19
  }
20
20
  export declare function getKustoWorker(): Promise<WorkerAccessor>;
21
21
  export declare const kustoDefaults: LanguageServiceDefaultsImpl;
22
- export declare const themeNames: {
23
- light: string;
24
- dark: string;
25
- dark2: string;
26
- };
@@ -1,13 +1,27 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
2
13
  import KustoCommandHighlighter from './commandHighlighter';
3
14
  import KustoCommandFormatter from './commandFormatter';
4
- import { extend, getCurrentCommandRange } from './extendedEditor';
5
- import { getCslTypeNameFromClrType, getCallName, getExpression, getInputParametersAsCslString, getEntityDataTypeFromCslType, } from './languageServiceManager/schema';
15
+ import { extend } from './extendedEditor';
16
+ import { themes } from './syntaxHighlighting/themes';
17
+ import { LANGUAGE_ID } from './globals';
18
+ import * as schema from './languageServiceManager/schema';
19
+ import { getRangeHtml } from './extendedGlobalApi';
6
20
  export * from './languageServiceManager/schema';
7
21
  export * from './languageServiceManager/renderInfo';
8
22
  export * from './languageServiceManager/settings';
9
23
  export * from './types';
10
- export { getCurrentCommandRange } from './extendedEditor';
24
+ export * from './extendedGlobalApi';
11
25
  // --- Kusto configuration and defaults ---------
12
26
  var LanguageServiceDefaultsImpl = /** @class */ (function () {
13
27
  function LanguageServiceDefaultsImpl(languageSettings) {
@@ -53,8 +67,6 @@ var defaultLanguageSettings = {
53
67
  includeControlCommands: true,
54
68
  newlineAfterPipe: true,
55
69
  openSuggestionDialogAfterPreviousSuggestionAccepted: true,
56
- useSemanticColorization: true,
57
- useTokenColorization: false,
58
70
  enableHover: true,
59
71
  formatter: {
60
72
  indentationSize: 4,
@@ -81,75 +93,16 @@ function withMode(callback) {
81
93
  import('./kustoMode').then(callback);
82
94
  }
83
95
  export var kustoDefaults = new LanguageServiceDefaultsImpl(defaultLanguageSettings);
84
- export var themeNames = {
85
- light: 'kusto-light',
86
- dark: 'kusto-dark',
87
- dark2: 'kusto-dark2',
88
- };
89
96
  monaco.languages.onLanguage('kusto', function () {
90
97
  withMode(function (mode) { return mode.setupMode(kustoDefaults, monaco); });
91
98
  });
92
99
  monaco.languages.register({
93
- id: 'kusto',
100
+ id: LANGUAGE_ID,
94
101
  extensions: ['.csl', '.kql'],
95
102
  });
96
- monaco.editor.defineTheme(themeNames.light, {
97
- base: 'vs',
98
- inherit: true,
99
- rules: [
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
115
- { token: 'invalid', background: 'cd3131' },
116
- ],
117
- colors: {},
118
- });
119
- monaco.editor.defineTheme(themeNames.dark, {
120
- base: 'vs-dark',
121
- inherit: true,
122
- rules: [
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
138
- { token: 'invalid', background: 'cd3131' },
139
- ],
140
- colors: {
141
- // see: https://code.visualstudio.com/api/references/theme-color#editor-widget-colors
142
- },
143
- });
144
- monaco.editor.defineTheme(themeNames.dark2, {
145
- base: 'vs-dark',
146
- inherit: true,
147
- rules: [],
148
- colors: {
149
- // see: https://code.visualstudio.com/api/references/theme-color#editor-widget-colors
150
- 'editor.background': '#1B1A19', // gray 200
151
- 'editorSuggestWidget.selectedBackground': '#004E8C',
152
- },
103
+ themes.forEach(function (_a) {
104
+ var name = _a.name, data = _a.data;
105
+ return monaco.editor.defineTheme(name, data);
153
106
  });
154
107
  // Initialize kusto specific language features that don't currently have a natural way to extend using existing apis.
155
108
  // Most other language features are initialized in kustoMode.ts
@@ -193,15 +146,5 @@ function triggerSuggestDialogWhenCompletionItemSelected(editor) {
193
146
  function isStandaloneCodeEditor(editor) {
194
147
  return editor.addAction !== undefined;
195
148
  }
196
- var globalApi = {
197
- getCslTypeNameFromClrType: getCslTypeNameFromClrType,
198
- getCallName: getCallName,
199
- getExpression: getExpression,
200
- getInputParametersAsCslString: getInputParametersAsCslString,
201
- getEntityDataTypeFromCslType: getEntityDataTypeFromCslType,
202
- kustoDefaults: kustoDefaults,
203
- getKustoWorker: getKustoWorker,
204
- getCurrentCommandRange: getCurrentCommandRange,
205
- themeNames: themeNames,
206
- };
149
+ var globalApi = __assign(__assign({}, schema), { kustoDefaults: kustoDefaults, getKustoWorker: getKustoWorker, getRangeHtml: getRangeHtml });
207
150
  monaco.languages.kusto = globalApi;