@kusto/monaco-kusto 6.1.2 → 7.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.
- package/README.md +39 -13
- package/globalApi.d.ts +13 -0
- package/package.json +6 -5
- package/release/dev/kustoMode.js +47 -31
- package/release/dev/kustoWorker.js +2 -2
- package/release/dev/{main-1f7cc4fa.js → main-5ef10bd7.js} +2 -2
- package/release/dev/monaco.contribution.js +306 -290
- package/release/esm/commandFormatter.d.ts +1 -1
- package/release/esm/commandHighlighter.d.ts +1 -2
- package/release/esm/extendedEditor.d.ts +2 -2
- package/release/esm/kusto.worker.js +1 -1
- package/release/esm/kustoMode.d.ts +4 -6
- package/release/esm/kustoMode.js +12 -15
- package/release/esm/kustoWorker.d.ts +1 -1
- package/release/esm/languageFeatures.d.ts +15 -21
- package/release/esm/languageService/kustoMonarchLanguageDefinition.d.ts +1 -1
- package/release/esm/languageService/settings.d.ts +2 -2
- package/release/esm/monaco.contribution.d.ts +12 -9
- package/release/esm/monaco.contribution.js +276 -282
- package/release/esm/types.d.ts +261 -0
- package/release/esm/workerManager.d.ts +4 -7
- package/release/min/kustoMode.js +2 -2
- package/release/min/kustoWorker.js +2 -2
- package/release/min/{main-d13ce646.js → main-c8dacaab.js} +2 -2
- package/release/min/monaco.contribution.js +2 -2
- package/release/monaco.d.ts +1 -319
|
@@ -1,11 +1,59 @@
|
|
|
1
1
|
/*!-----------------------------------------------------------------------------
|
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* monaco-kusto version:
|
|
3
|
+
* monaco-kusto version: 7.0.0(f23f8fe8dd705f8413d0d094c76eb0af2131aace)
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://https://github.com/Azure/monaco-kusto/blob/master/README.md
|
|
6
6
|
*-----------------------------------------------------------------------------*/
|
|
7
7
|
|
|
8
|
-
import 'monaco-editor';
|
|
8
|
+
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
|
9
|
+
|
|
10
|
+
function getCurrentCommandRange(editor, cursorPosition) {
|
|
11
|
+
const zeroBasedCursorLineNumber = cursorPosition.lineNumber - 1;
|
|
12
|
+
const lines = editor.getModel().getLinesContent();
|
|
13
|
+
let commandOrdinal = 0;
|
|
14
|
+
const linesWithCommandOrdinal = [];
|
|
15
|
+
for (let lineNumber = 0; lineNumber < lines.length; lineNumber++) {
|
|
16
|
+
let isEmptyLine = lines[lineNumber].trim() === '';
|
|
17
|
+
if (isEmptyLine) {
|
|
18
|
+
// increase commandCounter - we'll be starting a new command.
|
|
19
|
+
linesWithCommandOrdinal.push({
|
|
20
|
+
commandOrdinal: commandOrdinal++,
|
|
21
|
+
lineNumber
|
|
22
|
+
});
|
|
23
|
+
} else {
|
|
24
|
+
linesWithCommandOrdinal.push({
|
|
25
|
+
commandOrdinal: commandOrdinal,
|
|
26
|
+
lineNumber
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// No need to keep scanning if we're past our line and we've seen an empty line.
|
|
31
|
+
if (lineNumber > zeroBasedCursorLineNumber && commandOrdinal > linesWithCommandOrdinal[zeroBasedCursorLineNumber].commandOrdinal) {
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const currentCommandOrdinal = linesWithCommandOrdinal[zeroBasedCursorLineNumber].commandOrdinal;
|
|
36
|
+
const currentCommandLines = linesWithCommandOrdinal.filter(line => line.commandOrdinal === currentCommandOrdinal);
|
|
37
|
+
const currentCommandStartLine = currentCommandLines[0].lineNumber + 1;
|
|
38
|
+
const currentCommandEndLine = currentCommandLines[currentCommandLines.length - 1].lineNumber + 1;
|
|
39
|
+
|
|
40
|
+
// End-column of 1 means no characters will be highlighted - since columns are 1-based in monaco apis.
|
|
41
|
+
// Start-column of 1 and End column of 2 means 1st character is selected.
|
|
42
|
+
// Thus if a line has n column and we need to provide n+1 so that the entire line will be highlighted.
|
|
43
|
+
const commandEndColumn = lines[currentCommandEndLine - 1].length + 1;
|
|
44
|
+
return new monaco.Range(currentCommandStartLine, 1, currentCommandEndLine, commandEndColumn);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Extending ICode editor to contain additional kusto-specific methods.
|
|
49
|
+
* note that the extend method needs to be called at least once to take affect, otherwise this here code is useless.
|
|
50
|
+
*/
|
|
51
|
+
function extend(editor) {
|
|
52
|
+
const proto = Object.getPrototypeOf(editor);
|
|
53
|
+
proto.getCurrentCommandRange = function (cursorPosition) {
|
|
54
|
+
getCurrentCommandRange(this, cursorPosition);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
9
57
|
|
|
10
58
|
/**
|
|
11
59
|
* Highlights the command that surround cursor location
|
|
@@ -46,7 +94,7 @@ class KustoCommandHighlighter {
|
|
|
46
94
|
this.decorations = this.editor.deltaDecorations(this.decorations, []);
|
|
47
95
|
return;
|
|
48
96
|
}
|
|
49
|
-
const commandRange = this.editor
|
|
97
|
+
const commandRange = getCurrentCommandRange(this.editor, changeEvent.selection.getStartPosition());
|
|
50
98
|
const decorations = [{
|
|
51
99
|
range: commandRange,
|
|
52
100
|
options: KustoCommandHighlighter.CURRENT_COMMAND_HIGHLIGHT
|
|
@@ -66,7 +114,7 @@ class KustoCommandFormatter {
|
|
|
66
114
|
return;
|
|
67
115
|
}
|
|
68
116
|
// Theoretically you would expect this code to run only once in onDidCreateEditor.
|
|
69
|
-
// Turns out that onDidCreateEditor is fired before the IStandaloneEditor is completely created (it is
|
|
117
|
+
// Turns out that onDidCreateEditor is fired before the IStandaloneEditor is completely created (it is emitted by
|
|
70
118
|
// the super ctor before the child ctor was able to fully run).
|
|
71
119
|
// Thus we don't have a key binding provided yet when onDidCreateEditor is run, which is essential to call addAction.
|
|
72
120
|
// By adding the action here in onDidChangeCursorSelection we're making sure that the editor has a key binding provider,
|
|
@@ -87,52 +135,6 @@ class KustoCommandFormatter {
|
|
|
87
135
|
}
|
|
88
136
|
}
|
|
89
137
|
|
|
90
|
-
/**
|
|
91
|
-
* Extending ICode editor to contain additional kusto-specific methods.
|
|
92
|
-
* note that the extend method needs to be called at least once to take affect, otherwise this here code is useless.
|
|
93
|
-
*/
|
|
94
|
-
function extend(editor) {
|
|
95
|
-
const proto = Object.getPrototypeOf(editor);
|
|
96
|
-
proto.getCurrentCommandRange = function (cursorPosition) {
|
|
97
|
-
const zeroBasedCursorLineNumber = cursorPosition.lineNumber - 1;
|
|
98
|
-
const lines = this.getModel().getLinesContent();
|
|
99
|
-
let commandOrdinal = 0;
|
|
100
|
-
const linesWithCommandOrdinal = [];
|
|
101
|
-
for (let lineNumber = 0; lineNumber < lines.length; lineNumber++) {
|
|
102
|
-
let isEmptyLine = lines[lineNumber].trim() === '';
|
|
103
|
-
if (isEmptyLine) {
|
|
104
|
-
// increase commandCounter - we'll be starting a new command.
|
|
105
|
-
linesWithCommandOrdinal.push({
|
|
106
|
-
commandOrdinal: commandOrdinal++,
|
|
107
|
-
lineNumber
|
|
108
|
-
});
|
|
109
|
-
} else {
|
|
110
|
-
linesWithCommandOrdinal.push({
|
|
111
|
-
commandOrdinal: commandOrdinal,
|
|
112
|
-
lineNumber
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// No need to keep scanning if we're past our line and we've seen an empty line.
|
|
117
|
-
if (lineNumber > zeroBasedCursorLineNumber && commandOrdinal > linesWithCommandOrdinal[zeroBasedCursorLineNumber].commandOrdinal) {
|
|
118
|
-
break;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
const currentCommandOrdinal = linesWithCommandOrdinal[zeroBasedCursorLineNumber].commandOrdinal;
|
|
122
|
-
const currentCommandLines = linesWithCommandOrdinal.filter(line => line.commandOrdinal === currentCommandOrdinal);
|
|
123
|
-
const currentCommandStartLine = currentCommandLines[0].lineNumber + 1;
|
|
124
|
-
const currentCommandEndLine = currentCommandLines[currentCommandLines.length - 1].lineNumber + 1;
|
|
125
|
-
|
|
126
|
-
// End-column of 1 means no characters will be highlighted - since columns are 1-based in monaco apis.
|
|
127
|
-
// Start-column of 1 and End column of 2 means 1st character is selected.
|
|
128
|
-
// Thus if a line has n column and we need to provide n+1 so that the entire line will be highlighted.
|
|
129
|
-
const commandEndColumn = lines[currentCommandEndLine - 1].length + 1;
|
|
130
|
-
return new monaco.Range(currentCommandStartLine, 1, currentCommandEndLine, commandEndColumn);
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// Import monaco-editor to ensure "monaco" global is available before any other
|
|
135
|
-
|
|
136
138
|
// --- Kusto configuration and defaults ---------
|
|
137
139
|
|
|
138
140
|
class LanguageServiceDefaultsImpl {
|
|
@@ -200,244 +202,236 @@ function getKustoWorker() {
|
|
|
200
202
|
function withMode(callback) {
|
|
201
203
|
import('./kustoMode.js').then(callback);
|
|
202
204
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
205
|
+
const kustoDefaults = new LanguageServiceDefaultsImpl(defaultLanguageSettings);
|
|
206
|
+
monaco.languages.onLanguage('kusto', () => {
|
|
207
|
+
withMode(mode => mode.setupMode(kustoDefaults, monaco));
|
|
208
|
+
});
|
|
209
|
+
monaco.languages.register({
|
|
210
|
+
id: 'kusto',
|
|
211
|
+
extensions: ['.csl', '.kql']
|
|
212
|
+
});
|
|
213
|
+
monaco.editor.defineTheme('kusto-light', {
|
|
214
|
+
base: 'vs',
|
|
215
|
+
inherit: true,
|
|
216
|
+
rules: [{
|
|
217
|
+
token: 'comment',
|
|
218
|
+
foreground: '008000'
|
|
219
|
+
},
|
|
220
|
+
// CommentToken Green
|
|
221
|
+
{
|
|
222
|
+
token: 'variable.predefined',
|
|
223
|
+
foreground: '800080'
|
|
224
|
+
},
|
|
225
|
+
// CalculatedColumnToken Purple
|
|
226
|
+
{
|
|
227
|
+
token: 'function',
|
|
228
|
+
foreground: '0000FF'
|
|
229
|
+
},
|
|
230
|
+
// FunctionNameToken Blue
|
|
231
|
+
{
|
|
232
|
+
token: 'operator.sql',
|
|
233
|
+
foreground: 'CC3700'
|
|
234
|
+
},
|
|
235
|
+
// _WAS_ OperatorToken OrangeRed, but wasn't accessible.
|
|
236
|
+
{
|
|
237
|
+
token: 'string',
|
|
238
|
+
foreground: 'B22222'
|
|
239
|
+
},
|
|
240
|
+
// StringLiteralToken Firebrick
|
|
241
|
+
{
|
|
242
|
+
token: 'operator.scss',
|
|
243
|
+
foreground: '0000FF'
|
|
244
|
+
},
|
|
245
|
+
// SubOperatorToken Blue
|
|
246
|
+
{
|
|
247
|
+
token: 'variable',
|
|
248
|
+
foreground: 'C71585'
|
|
249
|
+
},
|
|
250
|
+
// TableColumnToken MediumVioletRed
|
|
251
|
+
{
|
|
252
|
+
token: 'variable.parameter',
|
|
253
|
+
foreground: '9932CC'
|
|
254
|
+
},
|
|
255
|
+
// TableToken DarkOrchid
|
|
256
|
+
{
|
|
257
|
+
token: '',
|
|
258
|
+
foreground: '000000'
|
|
259
|
+
},
|
|
260
|
+
// UnknownToken, PlainTextToken Black
|
|
261
|
+
{
|
|
262
|
+
token: 'type',
|
|
263
|
+
foreground: '0000FF'
|
|
264
|
+
},
|
|
265
|
+
// DataTypeToken Blue
|
|
266
|
+
{
|
|
267
|
+
token: 'tag',
|
|
268
|
+
foreground: '0000FF'
|
|
269
|
+
},
|
|
270
|
+
// ControlCommandToken Blue
|
|
271
|
+
{
|
|
272
|
+
token: 'annotation',
|
|
273
|
+
foreground: '2B91AF'
|
|
274
|
+
},
|
|
275
|
+
// QueryParametersToken FF2B91AF
|
|
276
|
+
{
|
|
277
|
+
token: 'keyword',
|
|
278
|
+
foreground: '0000FF'
|
|
279
|
+
},
|
|
280
|
+
// CslCommandToken, PluginToken Blue
|
|
281
|
+
{
|
|
282
|
+
token: 'number',
|
|
283
|
+
foreground: '191970'
|
|
284
|
+
},
|
|
285
|
+
// LetVariablesToken MidnightBlue
|
|
286
|
+
{
|
|
287
|
+
token: 'annotation',
|
|
288
|
+
foreground: '9400D3'
|
|
289
|
+
},
|
|
290
|
+
// ClientDirectiveToken DarkViolet
|
|
291
|
+
{
|
|
292
|
+
token: 'invalid',
|
|
293
|
+
background: 'cd3131'
|
|
294
|
+
}],
|
|
295
|
+
colors: {}
|
|
296
|
+
});
|
|
297
|
+
monaco.editor.defineTheme('kusto-dark', {
|
|
298
|
+
base: 'vs-dark',
|
|
299
|
+
inherit: true,
|
|
300
|
+
rules: [{
|
|
301
|
+
token: 'comment',
|
|
302
|
+
foreground: '608B4E'
|
|
303
|
+
},
|
|
304
|
+
// CommentToken Green
|
|
305
|
+
{
|
|
306
|
+
token: 'variable.predefined',
|
|
307
|
+
foreground: '4ec9b0'
|
|
308
|
+
},
|
|
309
|
+
// CalculatedColumnToken Purple
|
|
310
|
+
{
|
|
311
|
+
token: 'function',
|
|
312
|
+
foreground: 'dcdcaa'
|
|
313
|
+
},
|
|
314
|
+
// FunctionNameToken Blue
|
|
315
|
+
{
|
|
316
|
+
token: 'operator.sql',
|
|
317
|
+
foreground: '9cdcfe'
|
|
318
|
+
},
|
|
319
|
+
// OperatorToken OrangeRed
|
|
320
|
+
{
|
|
321
|
+
token: 'string',
|
|
322
|
+
foreground: 'ce9178'
|
|
323
|
+
},
|
|
324
|
+
// StringLiteralToken Firebrick
|
|
325
|
+
{
|
|
326
|
+
token: 'operator.scss',
|
|
327
|
+
foreground: '569cd6'
|
|
328
|
+
},
|
|
329
|
+
// SubOperatorToken Blue
|
|
330
|
+
{
|
|
331
|
+
token: 'variable',
|
|
332
|
+
foreground: '4ec9b0'
|
|
333
|
+
},
|
|
334
|
+
// TableColumnToken MediumVioletRed
|
|
335
|
+
{
|
|
336
|
+
token: 'variable.parameter',
|
|
337
|
+
foreground: 'c586c0'
|
|
338
|
+
},
|
|
339
|
+
// TableToken DarkOrchid
|
|
340
|
+
{
|
|
341
|
+
token: '',
|
|
342
|
+
foreground: 'd4d4d4'
|
|
343
|
+
},
|
|
344
|
+
// UnknownToken, PlainTextToken Black
|
|
345
|
+
{
|
|
346
|
+
token: 'type',
|
|
347
|
+
foreground: '569cd6'
|
|
348
|
+
},
|
|
349
|
+
// DataTypeToken Blue
|
|
350
|
+
{
|
|
351
|
+
token: 'tag',
|
|
352
|
+
foreground: '569cd6'
|
|
353
|
+
},
|
|
354
|
+
// ControlCommandToken Blue
|
|
355
|
+
{
|
|
356
|
+
token: 'annotation',
|
|
357
|
+
foreground: '9cdcfe'
|
|
358
|
+
},
|
|
359
|
+
// QueryParametersToken FF2B91AF
|
|
360
|
+
{
|
|
361
|
+
token: 'keyword',
|
|
362
|
+
foreground: '569cd6'
|
|
363
|
+
},
|
|
364
|
+
// CslCommandToken, PluginToken Blue
|
|
365
|
+
{
|
|
366
|
+
token: 'number',
|
|
367
|
+
foreground: 'd7ba7d'
|
|
368
|
+
},
|
|
369
|
+
// LetVariablesToken MidnightBlue
|
|
370
|
+
{
|
|
371
|
+
token: 'annotation',
|
|
372
|
+
foreground: 'b5cea8'
|
|
373
|
+
},
|
|
374
|
+
// ClientDirectiveToken DarkViolet
|
|
375
|
+
{
|
|
376
|
+
token: 'invalid',
|
|
377
|
+
background: 'cd3131'
|
|
378
|
+
}],
|
|
379
|
+
colors: {
|
|
380
|
+
// see: https://code.visualstudio.com/api/references/theme-color#editor-widget-colors
|
|
210
381
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
token: 'comment',
|
|
224
|
-
foreground: '008000'
|
|
225
|
-
},
|
|
226
|
-
// CommentToken Green
|
|
227
|
-
{
|
|
228
|
-
token: 'variable.predefined',
|
|
229
|
-
foreground: '800080'
|
|
230
|
-
},
|
|
231
|
-
// CalculatedColumnToken Purple
|
|
232
|
-
{
|
|
233
|
-
token: 'function',
|
|
234
|
-
foreground: '0000FF'
|
|
235
|
-
},
|
|
236
|
-
// FunctionNameToken Blue
|
|
237
|
-
{
|
|
238
|
-
token: 'operator.sql',
|
|
239
|
-
foreground: 'CC3700'
|
|
240
|
-
},
|
|
241
|
-
// _WAS_ OperatorToken OrangeRed, but wasn't accessible.
|
|
242
|
-
{
|
|
243
|
-
token: 'string',
|
|
244
|
-
foreground: 'B22222'
|
|
245
|
-
},
|
|
246
|
-
// StringLiteralToken Firebrick
|
|
247
|
-
{
|
|
248
|
-
token: 'operator.scss',
|
|
249
|
-
foreground: '0000FF'
|
|
250
|
-
},
|
|
251
|
-
// SubOperatorToken Blue
|
|
252
|
-
{
|
|
253
|
-
token: 'variable',
|
|
254
|
-
foreground: 'C71585'
|
|
255
|
-
},
|
|
256
|
-
// TableColumnToken MediumVioletRed
|
|
257
|
-
{
|
|
258
|
-
token: 'variable.parameter',
|
|
259
|
-
foreground: '9932CC'
|
|
260
|
-
},
|
|
261
|
-
// TableToken DarkOrchid
|
|
262
|
-
{
|
|
263
|
-
token: '',
|
|
264
|
-
foreground: '000000'
|
|
265
|
-
},
|
|
266
|
-
// UnknownToken, PlainTextToken Black
|
|
267
|
-
{
|
|
268
|
-
token: 'type',
|
|
269
|
-
foreground: '0000FF'
|
|
270
|
-
},
|
|
271
|
-
// DataTypeToken Blue
|
|
272
|
-
{
|
|
273
|
-
token: 'tag',
|
|
274
|
-
foreground: '0000FF'
|
|
275
|
-
},
|
|
276
|
-
// ControlCommandToken Blue
|
|
277
|
-
{
|
|
278
|
-
token: 'annotation',
|
|
279
|
-
foreground: '2B91AF'
|
|
280
|
-
},
|
|
281
|
-
// QueryParametersToken FF2B91AF
|
|
282
|
-
{
|
|
283
|
-
token: 'keyword',
|
|
284
|
-
foreground: '0000FF'
|
|
285
|
-
},
|
|
286
|
-
// CslCommandToken, PluginToken Blue
|
|
287
|
-
{
|
|
288
|
-
token: 'number',
|
|
289
|
-
foreground: '191970'
|
|
290
|
-
},
|
|
291
|
-
// LetVariablesToken MidnightBlue
|
|
292
|
-
{
|
|
293
|
-
token: 'annotation',
|
|
294
|
-
foreground: '9400D3'
|
|
295
|
-
},
|
|
296
|
-
// ClientDirectiveToken DarkViolet
|
|
297
|
-
{
|
|
298
|
-
token: 'invalid',
|
|
299
|
-
background: 'cd3131'
|
|
300
|
-
}],
|
|
301
|
-
colors: {}
|
|
302
|
-
});
|
|
303
|
-
monacoInstance.editor.defineTheme('kusto-dark', {
|
|
304
|
-
base: 'vs-dark',
|
|
305
|
-
inherit: true,
|
|
306
|
-
rules: [{
|
|
307
|
-
token: 'comment',
|
|
308
|
-
foreground: '608B4E'
|
|
309
|
-
},
|
|
310
|
-
// CommentToken Green
|
|
311
|
-
{
|
|
312
|
-
token: 'variable.predefined',
|
|
313
|
-
foreground: '4ec9b0'
|
|
314
|
-
},
|
|
315
|
-
// CalculatedColumnToken Purple
|
|
316
|
-
{
|
|
317
|
-
token: 'function',
|
|
318
|
-
foreground: 'dcdcaa'
|
|
319
|
-
},
|
|
320
|
-
// FunctionNameToken Blue
|
|
321
|
-
{
|
|
322
|
-
token: 'operator.sql',
|
|
323
|
-
foreground: '9cdcfe'
|
|
324
|
-
},
|
|
325
|
-
// OperatorToken OrangeRed
|
|
326
|
-
{
|
|
327
|
-
token: 'string',
|
|
328
|
-
foreground: 'ce9178'
|
|
329
|
-
},
|
|
330
|
-
// StringLiteralToken Firebrick
|
|
331
|
-
{
|
|
332
|
-
token: 'operator.scss',
|
|
333
|
-
foreground: '569cd6'
|
|
334
|
-
},
|
|
335
|
-
// SubOperatorToken Blue
|
|
336
|
-
{
|
|
337
|
-
token: 'variable',
|
|
338
|
-
foreground: '4ec9b0'
|
|
339
|
-
},
|
|
340
|
-
// TableColumnToken MediumVioletRed
|
|
341
|
-
{
|
|
342
|
-
token: 'variable.parameter',
|
|
343
|
-
foreground: 'c586c0'
|
|
344
|
-
},
|
|
345
|
-
// TableToken DarkOrchid
|
|
346
|
-
{
|
|
347
|
-
token: '',
|
|
348
|
-
foreground: 'd4d4d4'
|
|
349
|
-
},
|
|
350
|
-
// UnknownToken, PlainTextToken Black
|
|
351
|
-
{
|
|
352
|
-
token: 'type',
|
|
353
|
-
foreground: '569cd6'
|
|
354
|
-
},
|
|
355
|
-
// DataTypeToken Blue
|
|
356
|
-
{
|
|
357
|
-
token: 'tag',
|
|
358
|
-
foreground: '569cd6'
|
|
359
|
-
},
|
|
360
|
-
// ControlCommandToken Blue
|
|
361
|
-
{
|
|
362
|
-
token: 'annotation',
|
|
363
|
-
foreground: '9cdcfe'
|
|
364
|
-
},
|
|
365
|
-
// QueryParametersToken FF2B91AF
|
|
366
|
-
{
|
|
367
|
-
token: 'keyword',
|
|
368
|
-
foreground: '569cd6'
|
|
369
|
-
},
|
|
370
|
-
// CslCommandToken, PluginToken Blue
|
|
371
|
-
{
|
|
372
|
-
token: 'number',
|
|
373
|
-
foreground: 'd7ba7d'
|
|
374
|
-
},
|
|
375
|
-
// LetVariablesToken MidnightBlue
|
|
376
|
-
{
|
|
377
|
-
token: 'annotation',
|
|
378
|
-
foreground: 'b5cea8'
|
|
379
|
-
},
|
|
380
|
-
// ClientDirectiveToken DarkViolet
|
|
381
|
-
{
|
|
382
|
-
token: 'invalid',
|
|
383
|
-
background: 'cd3131'
|
|
384
|
-
}],
|
|
385
|
-
colors: {
|
|
386
|
-
// see: https://code.visualstudio.com/api/references/theme-color#editor-widget-colors
|
|
387
|
-
}
|
|
388
|
-
});
|
|
389
|
-
monacoInstance.editor.defineTheme('kusto-dark2', {
|
|
390
|
-
base: 'vs-dark',
|
|
391
|
-
inherit: true,
|
|
392
|
-
rules: [],
|
|
393
|
-
colors: {
|
|
394
|
-
// see: https://code.visualstudio.com/api/references/theme-color#editor-widget-colors
|
|
395
|
-
'editor.background': '#1B1A19',
|
|
396
|
-
// gray 200
|
|
397
|
-
'editorSuggestWidget.selectedBackground': '#004E8C'
|
|
398
|
-
}
|
|
399
|
-
});
|
|
382
|
+
});
|
|
383
|
+
monaco.editor.defineTheme('kusto-dark2', {
|
|
384
|
+
base: 'vs-dark',
|
|
385
|
+
inherit: true,
|
|
386
|
+
rules: [],
|
|
387
|
+
colors: {
|
|
388
|
+
// see: https://code.visualstudio.com/api/references/theme-color#editor-widget-colors
|
|
389
|
+
'editor.background': '#1B1A19',
|
|
390
|
+
// gray 200
|
|
391
|
+
'editorSuggestWidget.selectedBackground': '#004E8C'
|
|
392
|
+
}
|
|
393
|
+
});
|
|
400
394
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
395
|
+
// Initialize kusto specific language features that don't currently have a natural way to extend using existing apis.
|
|
396
|
+
// Most other language features are initialized in kustoMode.ts
|
|
397
|
+
monaco.editor.onDidCreateEditor(editor => {
|
|
398
|
+
// hook up extension methods to editor.
|
|
399
|
+
extend(editor);
|
|
400
|
+
new KustoCommandHighlighter(editor);
|
|
401
|
+
if (isStandaloneCodeEditor(editor)) {
|
|
402
|
+
new KustoCommandFormatter(editor);
|
|
403
|
+
}
|
|
404
|
+
triggerSuggestDialogWhenCompletionItemSelected(editor);
|
|
405
|
+
});
|
|
406
|
+
function triggerSuggestDialogWhenCompletionItemSelected(editor) {
|
|
407
|
+
editor.onDidChangeCursorSelection(event => {
|
|
408
|
+
// checking the condition inside the event makes sure we will stay up to date when kusto configuration changes at runtime.
|
|
409
|
+
if (kustoDefaults && kustoDefaults.languageSettings && kustoDefaults.languageSettings.openSuggestionDialogAfterPreviousSuggestionAccepted) {
|
|
410
|
+
var didAcceptSuggestion = event.source === 'snippet' && event.reason === monaco.editor.CursorChangeReason.NotSet;
|
|
411
|
+
// If the word at the current position is not null - meaning we did not add a space after completion.
|
|
412
|
+
// In this case we don't want to activate the eager mode, since it will display the current selected word..
|
|
413
|
+
if (!didAcceptSuggestion || editor.getModel().getWordAtPosition(event.selection.getPosition()) !== null) {
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
event.selection;
|
|
417
|
+
// OK so now we in a situation where we know a suggestion was selected and we want to trigger another one.
|
|
418
|
+
// the only problem is that the suggestion widget itself listens to this same event in order to know it needs to close.
|
|
419
|
+
// The only problem is that we're ahead in line, so we're triggering a suggest operation that will be shut down once
|
|
420
|
+
// the next callback is called. This is why we're waiting here - to let all the callbacks run synchronously and be
|
|
421
|
+
// the 'last' subscriber to run. Granted this is hacky, but until monaco provides a specific event for suggestions,
|
|
422
|
+
// this is the best we have.
|
|
423
|
+
setTimeout(() => editor.trigger('monaco-kusto', 'editor.action.triggerSuggest', {}), 10);
|
|
409
424
|
}
|
|
410
|
-
triggerSuggestDialogWhenCompletionItemSelected(editor);
|
|
411
425
|
});
|
|
412
|
-
function triggerSuggestDialogWhenCompletionItemSelected(editor) {
|
|
413
|
-
editor.onDidChangeCursorSelection(event => {
|
|
414
|
-
// checking the condition inside the event makes sure we will stay up to date when kusto configuration changes at runtime.
|
|
415
|
-
if (kustoDefaults && kustoDefaults.languageSettings && kustoDefaults.languageSettings.openSuggestionDialogAfterPreviousSuggestionAccepted) {
|
|
416
|
-
var didAcceptSuggestion = event.source === 'snippet' && event.reason === monaco.editor.CursorChangeReason.NotSet;
|
|
417
|
-
// If the word at the current position is not null - meaning we did not add a space after completion.
|
|
418
|
-
// In this case we don't want to activate the eager mode, since it will display the current selected word..
|
|
419
|
-
if (!didAcceptSuggestion || editor.getModel().getWordAtPosition(event.selection.getPosition()) !== null) {
|
|
420
|
-
return;
|
|
421
|
-
}
|
|
422
|
-
event.selection;
|
|
423
|
-
// OK so now we in a situation where we know a suggestion was selected and we want to trigger another one.
|
|
424
|
-
// the only problem is that the suggestion widget itself listens to this same event in order to know it needs to close.
|
|
425
|
-
// The only problem is that we're ahead in line, so we're triggering a suggest operation that will be shut down once
|
|
426
|
-
// the next callback is called. This is why we're waiting here - to let all the callbacks run synchronously and be
|
|
427
|
-
// the 'last' subscriber to run. Granted this is hacky, but until monaco provides a specific event for suggestions,
|
|
428
|
-
// this is the best we have.
|
|
429
|
-
setTimeout(() => editor.trigger('monaco-kusto', 'editor.action.triggerSuggest', {}), 10);
|
|
430
|
-
}
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
426
|
}
|
|
434
427
|
function isStandaloneCodeEditor(editor) {
|
|
435
428
|
return editor.addAction !== undefined;
|
|
436
429
|
}
|
|
430
|
+
const globalApi = {
|
|
431
|
+
kustoDefaults,
|
|
432
|
+
getKustoWorker,
|
|
433
|
+
getCurrentCommandRange
|
|
434
|
+
};
|
|
435
|
+
monaco.languages.kusto = globalApi;
|
|
437
436
|
|
|
438
|
-
|
|
439
|
-
if (monaco.editor) {
|
|
440
|
-
setupMonacoKusto(monaco);
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
export { LanguageServiceDefaultsImpl, setupMonacoKusto };
|
|
437
|
+
export { getCurrentCommandRange, getKustoWorker, kustoDefaults };
|