@kusto/monaco-kusto 11.4.0 → 12.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -1
- package/package.json +3 -1
- package/release/dev/kustoMode-d3f9e09a.js +1818 -0
- package/release/dev/kustoMode.js +4 -2040
- package/release/dev/kustoWorker.js +49 -90
- package/release/dev/{main-1587ba64.js → main-f36cb42f.js} +2 -2
- package/release/dev/monaco.contribution.js +254 -214
- package/release/dev/{schema-a5230652.js → schema-077630e6.js} +13 -2
- package/release/esm/extendedGlobalApi/getRangeHtml.d.ts +2 -0
- package/release/esm/extendedGlobalApi/getRangeHtml.js +11 -0
- package/release/esm/extendedGlobalApi/index.d.ts +1 -0
- package/release/esm/extendedGlobalApi/index.js +1 -0
- package/release/esm/globals.d.ts +1 -0
- package/release/esm/globals.js +1 -0
- package/release/esm/kusto.worker.js +39 -91
- package/release/esm/kustoMode-349f5467.js +957 -0
- package/release/esm/kustoMode.d.ts +4 -8
- package/release/esm/kustoMode.js +94 -104
- package/release/esm/kustoWorker.d.ts +2 -5
- package/release/esm/kustoWorker.js +2 -5
- package/release/esm/languageFeatures.d.ts +1 -14
- package/release/esm/languageFeatures.js +0 -299
- package/release/esm/languageServiceManager/kustoLanguageService.d.ts +2 -4
- package/release/esm/languageServiceManager/kustoLanguageService.js +58 -71
- package/release/esm/languageServiceManager/schema.d.ts +2 -2
- package/release/esm/languageServiceManager/settings.d.ts +0 -2
- package/release/esm/monaco.contribution.d.ts +1 -6
- package/release/esm/monaco.contribution.js +64 -88
- package/release/esm/{schema-c006895b.js → schema-b8f0ba9b.js} +12 -2
- package/release/esm/syntaxHighlighting/SemanticTokensProvider.d.ts +18 -0
- package/release/esm/syntaxHighlighting/SemanticTokensProvider.js +78 -0
- package/release/esm/syntaxHighlighting/kustoMonarchLanguageDefinition.d.ts +2 -0
- package/release/esm/syntaxHighlighting/kustoMonarchLanguageDefinition.js +401 -0
- package/release/esm/syntaxHighlighting/semanticTokensProviderRegistrar.d.ts +6 -0
- package/release/esm/syntaxHighlighting/semanticTokensProviderRegistrar.js +23 -0
- package/release/esm/syntaxHighlighting/themes.d.ts +11 -0
- package/release/esm/syntaxHighlighting/themes.js +103 -0
- package/release/esm/syntaxHighlighting/types.d.ts +41 -0
- package/release/esm/syntaxHighlighting/types.js +55 -0
- package/release/min/kustoMode-2dd4a01e.js +7 -0
- package/release/min/kustoMode.js +2 -2
- package/release/min/kustoWorker.js +4 -4
- package/release/min/{main-75aa3e71.js → main-86d6c837.js} +2 -2
- package/release/min/monaco.contribution.js +2 -2
- package/release/min/schema-a60c216c.js +7 -0
- package/release/esm/languageServiceManager/kustoMonarchLanguageDefinition.d.ts +0 -2
- package/release/esm/languageServiceManager/kustoMonarchLanguageDefinition.js +0 -211
- package/release/min/schema-192b3175.js +0 -7
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import { KustoWorker, LanguageServiceDefaults } from './monaco.contribution';
|
|
3
|
+
import { IKustoWorkerImpl } from './kustoWorker';
|
|
4
4
|
export interface AugmentedWorker extends KustoWorker, Omit<IKustoWorkerImpl, 'setSchemaFromShowSchema' | 'getReferencedSymbols'> {
|
|
5
5
|
}
|
|
6
6
|
export interface AugmentedWorkerAccessor {
|
|
7
|
-
(first: monaco.Uri
|
|
7
|
+
(first: monaco.Uri): Promise<AugmentedWorker>;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
* Called when Kusto language is first needed (a model has the language set)
|
|
11
|
-
* @param defaults
|
|
12
|
-
*/
|
|
13
|
-
export declare function setupMode(defaults: LanguageServiceDefaults, monacoInstance: typeof globalThis.monaco): AugmentedWorkerAccessor;
|
|
9
|
+
export declare function setupMode(defaults: LanguageServiceDefaults, monacoInstance: typeof monaco): Promise<AugmentedWorkerAccessor>;
|
|
14
10
|
export declare function getKustoWorker(): Promise<AugmentedWorkerAccessor>;
|
package/release/esm/kustoMode.js
CHANGED
|
@@ -47,115 +47,105 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
47
47
|
};
|
|
48
48
|
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
|
49
49
|
import { WorkerManager } from './workerManager';
|
|
50
|
-
import { KustoLanguageDefinition } from './languageServiceManager/kustoMonarchLanguageDefinition';
|
|
51
50
|
import * as languageFeatures from './languageFeatures';
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
var
|
|
56
|
-
resolveWorker = resolve;
|
|
57
|
-
rejectWorker = reject;
|
|
58
|
-
});
|
|
59
|
-
/**
|
|
60
|
-
* Called when Kusto language is first needed (a model has the language set)
|
|
61
|
-
* @param defaults
|
|
62
|
-
*/
|
|
51
|
+
import { LANGUAGE_ID } from './globals';
|
|
52
|
+
import { semanticTokensProviderRegistrarCreator } from './syntaxHighlighting/semanticTokensProviderRegistrar';
|
|
53
|
+
import { kustoLanguageDefinition } from './syntaxHighlighting/kustoMonarchLanguageDefinition';
|
|
54
|
+
var workerAccessor;
|
|
63
55
|
export function setupMode(defaults, monacoInstance) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
56
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
57
|
+
var onSchemaChange, client, semanticTokensProviderRegistrar, completionAdapter, documentRangeFormattingAdapter, foldingRangeAdapter, definitionProvider, referenceProvider, hoverAdapter, documentFormattingAdapter, languageConfiguration;
|
|
58
|
+
var _this = this;
|
|
59
|
+
return __generator(this, function (_a) {
|
|
60
|
+
onSchemaChange = new monaco.Emitter();
|
|
61
|
+
client = new WorkerManager(monacoInstance, defaults);
|
|
62
|
+
semanticTokensProviderRegistrar = semanticTokensProviderRegistrarCreator();
|
|
63
|
+
workerAccessor = function (uri) { return __awaiter(_this, void 0, void 0, function () {
|
|
64
|
+
var worker, augmentedSetSchema, setSchemaFromShowSchema;
|
|
65
|
+
var _this = this;
|
|
66
|
+
return __generator(this, function (_a) {
|
|
67
|
+
switch (_a.label) {
|
|
68
|
+
case 0: return [4 /*yield*/, client.getLanguageServiceWorker(uri)];
|
|
69
|
+
case 1:
|
|
70
|
+
worker = _a.sent();
|
|
71
|
+
augmentedSetSchema = function (schema) { return __awaiter(_this, void 0, void 0, function () {
|
|
72
|
+
return __generator(this, function (_a) {
|
|
73
|
+
switch (_a.label) {
|
|
74
|
+
case 0: return [4 /*yield*/, worker.setSchema(schema)];
|
|
75
|
+
case 1:
|
|
76
|
+
_a.sent();
|
|
77
|
+
onSchemaChange.fire(schema);
|
|
78
|
+
semanticTokensProviderRegistrar(monacoInstance, worker);
|
|
79
|
+
return [2 /*return*/];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}); };
|
|
83
|
+
setSchemaFromShowSchema = function (schema, clusterConnectionString, databaseInContextName, globalScalarParameters, globalTabularParameters) { return __awaiter(_this, void 0, void 0, function () {
|
|
84
|
+
var normalizedSchema;
|
|
85
|
+
return __generator(this, function (_a) {
|
|
86
|
+
switch (_a.label) {
|
|
87
|
+
case 0: return [4 /*yield*/, worker.normalizeSchema(schema, clusterConnectionString, databaseInContextName)];
|
|
88
|
+
case 1:
|
|
89
|
+
normalizedSchema = _a.sent();
|
|
90
|
+
normalizedSchema.globalScalarParameters = globalScalarParameters;
|
|
91
|
+
normalizedSchema.globalTabularParameters = globalTabularParameters;
|
|
92
|
+
return [4 /*yield*/, augmentedSetSchema(normalizedSchema)];
|
|
93
|
+
case 2:
|
|
94
|
+
_a.sent();
|
|
95
|
+
return [2 /*return*/];
|
|
99
96
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return [2 /*return*/];
|
|
105
|
-
}
|
|
106
|
-
});
|
|
97
|
+
});
|
|
98
|
+
}); };
|
|
99
|
+
return [2 /*return*/, __assign(__assign({}, worker), { setSchema: augmentedSetSchema, setSchemaFromShowSchema: setSchemaFromShowSchema })];
|
|
100
|
+
}
|
|
107
101
|
});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
autoClosingPairs: [
|
|
150
|
-
{ open: '{', close: '}' },
|
|
151
|
-
{ open: '[', close: ']' },
|
|
152
|
-
{ open: '(', close: ')' },
|
|
153
|
-
{ open: "'", close: "'", notIn: ['string', 'comment'] },
|
|
154
|
-
{ open: '"', close: '"', notIn: ['string', 'comment'] },
|
|
155
|
-
],
|
|
102
|
+
}); };
|
|
103
|
+
monacoInstance.languages.setMonarchTokensProvider(LANGUAGE_ID, kustoLanguageDefinition);
|
|
104
|
+
completionAdapter = new languageFeatures.CompletionAdapter(workerAccessor, defaults.languageSettings);
|
|
105
|
+
monacoInstance.languages.registerCompletionItemProvider(LANGUAGE_ID, completionAdapter);
|
|
106
|
+
// this constructor has side effects and therefore doesn't need to be passed anywhere
|
|
107
|
+
new languageFeatures.DiagnosticsAdapter(monacoInstance, LANGUAGE_ID, workerAccessor, defaults, onSchemaChange.event);
|
|
108
|
+
documentRangeFormattingAdapter = new languageFeatures.FormatAdapter(workerAccessor);
|
|
109
|
+
monacoInstance.languages.registerDocumentRangeFormattingEditProvider(LANGUAGE_ID, documentRangeFormattingAdapter);
|
|
110
|
+
foldingRangeAdapter = new languageFeatures.FoldingAdapter(workerAccessor);
|
|
111
|
+
monacoInstance.languages.registerFoldingRangeProvider(LANGUAGE_ID, foldingRangeAdapter);
|
|
112
|
+
definitionProvider = new languageFeatures.DefinitionAdapter(workerAccessor);
|
|
113
|
+
monacoInstance.languages.registerDefinitionProvider(LANGUAGE_ID, definitionProvider);
|
|
114
|
+
monacoInstance.languages.registerRenameProvider(LANGUAGE_ID, new languageFeatures.RenameAdapter(workerAccessor));
|
|
115
|
+
referenceProvider = new languageFeatures.ReferenceAdapter(workerAccessor);
|
|
116
|
+
monacoInstance.languages.registerReferenceProvider(LANGUAGE_ID, referenceProvider);
|
|
117
|
+
if (defaults.languageSettings.enableHover) {
|
|
118
|
+
hoverAdapter = new languageFeatures.HoverAdapter(workerAccessor);
|
|
119
|
+
monacoInstance.languages.registerHoverProvider(LANGUAGE_ID, hoverAdapter);
|
|
120
|
+
}
|
|
121
|
+
documentFormattingAdapter = new languageFeatures.DocumentFormatAdapter(workerAccessor);
|
|
122
|
+
monacoInstance.languages.registerDocumentFormattingEditProvider(LANGUAGE_ID, documentFormattingAdapter);
|
|
123
|
+
languageConfiguration = {
|
|
124
|
+
folding: {
|
|
125
|
+
offSide: false,
|
|
126
|
+
markers: { start: /^\s*[\r\n]/gm, end: /^\s*[\r\n]/gm },
|
|
127
|
+
},
|
|
128
|
+
comments: {
|
|
129
|
+
lineComment: '//',
|
|
130
|
+
blockComment: null,
|
|
131
|
+
},
|
|
132
|
+
autoClosingPairs: [
|
|
133
|
+
{ open: '{', close: '}' },
|
|
134
|
+
{ open: '[', close: ']' },
|
|
135
|
+
{ open: '(', close: ')' },
|
|
136
|
+
{ open: "'", close: "'", notIn: ['string', 'comment'] },
|
|
137
|
+
{ open: '"', close: '"', notIn: ['string', 'comment'] },
|
|
138
|
+
],
|
|
139
|
+
};
|
|
140
|
+
monacoInstance.languages.setLanguageConfiguration(LANGUAGE_ID, languageConfiguration);
|
|
141
|
+
return [2 /*return*/, workerAccessor];
|
|
142
|
+
});
|
|
156
143
|
});
|
|
157
|
-
return kustoWorker;
|
|
158
144
|
}
|
|
159
145
|
export function getKustoWorker() {
|
|
160
|
-
return
|
|
146
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
147
|
+
return __generator(this, function (_a) {
|
|
148
|
+
return [2 /*return*/, workerAccessor];
|
|
149
|
+
});
|
|
150
|
+
});
|
|
161
151
|
}
|
|
@@ -4,9 +4,9 @@ import type { IRange } from 'monaco-editor/esm/vs/editor/editor.api';
|
|
|
4
4
|
import * as kustoService from './languageServiceManager/kustoLanguageService';
|
|
5
5
|
import type { LanguageSettings } from './languageServiceManager/settings';
|
|
6
6
|
import { Schema, showSchema, ScalarParameter, Database, TabularParameter } from './languageServiceManager/schema';
|
|
7
|
-
import type { ColorizationRange } from './languageServiceManager/kustoLanguageService';
|
|
8
7
|
import type { RenderInfo } from './languageServiceManager/renderInfo';
|
|
9
8
|
import type { ClusterReference, DatabaseReference } from './types';
|
|
9
|
+
import { ClassificationRange } from './syntaxHighlighting/types';
|
|
10
10
|
export type InterfaceFor<C> = {
|
|
11
11
|
[Member in keyof C]: C[Member];
|
|
12
12
|
};
|
|
@@ -75,10 +75,7 @@ export declare class KustoWorkerImpl {
|
|
|
75
75
|
doFolding(uri: string): Promise<ls.FoldingRange[]>;
|
|
76
76
|
doDocumentFormat(uri: string): Promise<ls.TextEdit[]>;
|
|
77
77
|
doCurrentCommandFormat(uri: string, caretPosition: ls.Position): Promise<ls.TextEdit[]>;
|
|
78
|
-
|
|
79
|
-
start: number;
|
|
80
|
-
end: number;
|
|
81
|
-
}[]): Promise<ColorizationRange[]>;
|
|
78
|
+
getClassifications(uri: string): Promise<ClassificationRange[]>;
|
|
82
79
|
getClientDirective(text: string): Promise<{
|
|
83
80
|
isClientDirective: boolean;
|
|
84
81
|
directiveWithoutLeadingComments: string;
|
|
@@ -7,7 +7,6 @@ var KustoWorkerImpl = /** @class */ (function () {
|
|
|
7
7
|
this._languageService = kustoService.getKustoLanguageService();
|
|
8
8
|
this._languageService.configure(this._languageSettings);
|
|
9
9
|
}
|
|
10
|
-
// --- language service host ---------------
|
|
11
10
|
KustoWorkerImpl.prototype.setSchema = function (schema) {
|
|
12
11
|
return this._languageService.setSchema(schema);
|
|
13
12
|
};
|
|
@@ -182,11 +181,9 @@ var KustoWorkerImpl = /** @class */ (function () {
|
|
|
182
181
|
var formatted = this._languageService.doCurrentCommandFormat(document, caretPosition);
|
|
183
182
|
return formatted;
|
|
184
183
|
};
|
|
185
|
-
|
|
186
|
-
KustoWorkerImpl.prototype.doColorization = function (uri, colorizationIntervals) {
|
|
184
|
+
KustoWorkerImpl.prototype.getClassifications = function (uri) {
|
|
187
185
|
var document = this._getTextDocument(uri);
|
|
188
|
-
|
|
189
|
-
return colorizationInfo;
|
|
186
|
+
return this._languageService.getClassifications(document);
|
|
190
187
|
};
|
|
191
188
|
KustoWorkerImpl.prototype.getClientDirective = function (text) {
|
|
192
189
|
return this._languageService.getClientDirective(text);
|
|
@@ -13,25 +13,12 @@ export declare class DiagnosticsAdapter {
|
|
|
13
13
|
private _schemaListener;
|
|
14
14
|
private _cursorListener;
|
|
15
15
|
private _debouncedValidations;
|
|
16
|
-
constructor(_monacoInstance: typeof
|
|
16
|
+
constructor(_monacoInstance: typeof monaco, _languageId: string, _worker: AugmentedWorkerAccessor, defaults: LanguageServiceDefaults, onSchemaChange: monaco.IEvent<Schema>);
|
|
17
17
|
private getMonacoCodeActions;
|
|
18
18
|
private getOrCreateDebouncedValidation;
|
|
19
19
|
dispose(): void;
|
|
20
20
|
private _doValidate;
|
|
21
21
|
}
|
|
22
|
-
export declare class ColorizationAdapter {
|
|
23
|
-
private _monacoInstance;
|
|
24
|
-
private _languageId;
|
|
25
|
-
private _worker;
|
|
26
|
-
private _disposables;
|
|
27
|
-
private _contentListener;
|
|
28
|
-
private _configurationListener;
|
|
29
|
-
private _schemaListener;
|
|
30
|
-
private decorations;
|
|
31
|
-
constructor(_monacoInstance: typeof globalThis.monaco, _languageId: string, _worker: AugmentedWorkerAccessor, defaults: LanguageServiceDefaults, onSchemaChange: monaco.IEvent<Schema>);
|
|
32
|
-
dispose(): void;
|
|
33
|
-
private _doColorization;
|
|
34
|
-
}
|
|
35
22
|
export declare class CompletionAdapter implements monaco.languages.CompletionItemProvider {
|
|
36
23
|
private readonly languageSettings;
|
|
37
24
|
private completionCacheManager;
|
|
@@ -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
|
-
|
|
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>;
|