@kusto/monaco-kusto 5.6.5 → 6.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 (65) hide show
  1. package/package.json +26 -16
  2. package/release/dev/commandFormatter.d.ts +6 -0
  3. package/release/dev/commandHighlighter.d.ts +20 -0
  4. package/release/dev/extendedEditor.d.ts +7 -0
  5. package/release/dev/kustoMode.d.ts +8 -0
  6. package/release/dev/kustoMode.js +1732 -3278
  7. package/release/dev/kustoWorker.d.ts +92 -0
  8. package/release/dev/kustoWorker.js +5663 -8534
  9. package/release/dev/languageFeatures.d.ts +91 -0
  10. package/release/dev/languageService/kustoLanguageService.d.ts +142 -0
  11. package/release/dev/languageService/kustoMonarchLanguageDefinition.d.ts +1 -0
  12. package/release/dev/languageService/renderInfo.d.ts +31 -0
  13. package/release/dev/languageService/schema.d.ts +144 -0
  14. package/release/dev/languageService/settings.d.ts +30 -0
  15. package/release/dev/main-24a15f15.js +1958 -0
  16. package/release/dev/monaco.contribution.d.ts +15 -0
  17. package/release/dev/monaco.contribution.js +462 -308
  18. package/release/dev/workerManager.d.ts +23 -0
  19. package/release/esm/commandFormatter.d.ts +6 -0
  20. package/release/esm/commandHighlighter.d.ts +20 -0
  21. package/release/esm/extendedEditor.d.ts +7 -0
  22. package/release/esm/kusto.worker.js +2224 -5
  23. package/release/esm/kustoMode.d.ts +8 -0
  24. package/release/esm/kustoMode.js +1120 -88
  25. package/release/esm/kustoWorker.d.ts +92 -0
  26. package/release/esm/languageFeatures.d.ts +91 -0
  27. package/release/esm/languageService/kustoLanguageService.d.ts +142 -0
  28. package/release/esm/languageService/kustoMonarchLanguageDefinition.d.ts +1 -0
  29. package/release/esm/languageService/renderInfo.d.ts +31 -0
  30. package/release/esm/languageService/schema.d.ts +144 -0
  31. package/release/esm/languageService/settings.d.ts +30 -0
  32. package/release/esm/monaco.contribution.d.ts +1 -0
  33. package/release/esm/monaco.contribution.js +424 -180
  34. package/release/esm/workerManager.d.ts +23 -0
  35. package/release/min/commandFormatter.d.ts +6 -0
  36. package/release/min/commandHighlighter.d.ts +20 -0
  37. package/release/min/extendedEditor.d.ts +7 -0
  38. package/release/min/kustoMode.d.ts +8 -0
  39. package/release/min/kustoMode.js +2 -11
  40. package/release/min/kustoWorker.d.ts +92 -0
  41. package/release/min/kustoWorker.js +10 -53
  42. package/release/min/languageFeatures.d.ts +91 -0
  43. package/release/min/languageService/kustoLanguageService.d.ts +142 -0
  44. package/release/min/languageService/kustoMonarchLanguageDefinition.d.ts +1 -0
  45. package/release/min/languageService/renderInfo.d.ts +31 -0
  46. package/release/min/languageService/schema.d.ts +144 -0
  47. package/release/min/languageService/settings.d.ts +30 -0
  48. package/release/min/main-1108181b.js +7 -0
  49. package/release/min/monaco.contribution.d.ts +1 -0
  50. package/release/min/monaco.contribution.js +2 -2
  51. package/release/min/monaco.d.ts +1 -318
  52. package/release/min/workerManager.d.ts +23 -0
  53. package/release/{esm/monaco.d.ts → monaco.d.ts} +1 -0
  54. package/release/esm/_deps/lodash/lodash.js +0 -17209
  55. package/release/esm/_deps/vscode-languageserver-types/main.js +0 -1908
  56. package/release/esm/_deps/xregexp/xregexp-all.js +0 -4652
  57. package/release/esm/commandFormatter.js +0 -36
  58. package/release/esm/commandHighlighter.js +0 -51
  59. package/release/esm/extendedEditor.js +0 -38
  60. package/release/esm/kustoWorker.js +0 -245
  61. package/release/esm/languageFeatures.js +0 -1030
  62. package/release/esm/languageService/kustoLanguageService.js +0 -1912
  63. package/release/esm/languageService/kustoMonarchLanguageDefinition.js +0 -127
  64. package/release/esm/languageService/schema.js +0 -64
  65. package/release/esm/workerManager.js +0 -102
@@ -1,197 +1,441 @@
1
- var Emitter = monaco.Emitter;
2
- import KustoCommandHighlighter from './commandHighlighter';
3
- import KustoCommandFormatter from './commandFormatter';
4
- import { extend } from './extendedEditor';
5
- // --- Kusto configuration and defaults ---------
6
- var LanguageServiceDefaultsImpl = /** @class */ (function () {
7
- function LanguageServiceDefaultsImpl(languageSettings) {
8
- this._onDidChange = new Emitter();
9
- this.setLanguageSettings(languageSettings);
10
- // default to never kill worker when idle.
11
- // reason: when killing worker - schema gets lost. We transmit the schema back to main process when killing
12
- // the worker, but in some extreme cases web worker runs out of memory while stringifying the schema.
13
- // This stems from the fact that web workers have much more limited memory that the main process.
14
- // An alternative solution (not currently implemented) is to just save the schema in the main process whenever calling
15
- // setSchema. That way we don't need to stringify the schema on the worker side when killing the web worker.
16
- this._workerMaxIdleTime = 0;
17
- }
18
- Object.defineProperty(LanguageServiceDefaultsImpl.prototype, "onDidChange", {
19
- get: function () {
20
- return this._onDidChange.event;
21
- },
22
- enumerable: false,
23
- configurable: true
1
+ /*!-----------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * monaco-kusto version: 6.0.0(d333d5bf2aa3d56b17120ed36803a7fb5bcfb87a)
4
+ * Released under the MIT license
5
+ * https://https://github.com/Azure/monaco-kusto/blob/master/README.md
6
+ *-----------------------------------------------------------------------------*/
7
+
8
+ /**
9
+ * Highlights the command that surround cursor location
10
+ */
11
+ class KustoCommandHighlighter {
12
+ static ID = 'editor.contrib.kustoCommandHighliter';
13
+ static CURRENT_COMMAND_HIGHLIGHT = {
14
+ className: 'selectionHighlight'
15
+ };
16
+ disposables = [];
17
+ decorations = [];
18
+
19
+ /**
20
+ * Register to cursor movement and seleciton events.
21
+ * @param editor monaco editor instance
22
+ */
23
+ constructor(editor) {
24
+ this.editor = editor;
25
+ // Note that selection update is triggered not only for selection changes, but also just when no text selection is occuring and cursor just moves around.
26
+ // This case is counted as a 0-length selection starting and ending on the cursor position.
27
+ this.editor.onDidChangeCursorSelection(changeEvent => {
28
+ if (this.editor.getModel().getLanguageId() !== 'kusto') {
29
+ return;
30
+ }
31
+ this.highlightCommandUnderCursor(changeEvent);
24
32
  });
25
- Object.defineProperty(LanguageServiceDefaultsImpl.prototype, "languageSettings", {
26
- get: function () {
27
- return this._languageSettings;
28
- },
29
- enumerable: false,
30
- configurable: true
33
+ }
34
+ getId() {
35
+ return KustoCommandHighlighter.ID;
36
+ }
37
+ dispose() {
38
+ this.disposables.forEach(d => d.dispose());
39
+ }
40
+ highlightCommandUnderCursor(changeEvent) {
41
+ // Looks like the user selected a bunch of text. we don't want to highlight the entire command in this case - since highlighting
42
+ // the text is more helpful.
43
+ if (!changeEvent.selection.isEmpty()) {
44
+ this.decorations = this.editor.deltaDecorations(this.decorations, []);
45
+ return;
46
+ }
47
+ const commandRange = this.editor.getCurrentCommandRange(changeEvent.selection.getStartPosition());
48
+ const decorations = [{
49
+ range: commandRange,
50
+ options: KustoCommandHighlighter.CURRENT_COMMAND_HIGHLIGHT
51
+ }];
52
+ this.decorations = this.editor.deltaDecorations(this.decorations, decorations);
53
+ }
54
+ }
55
+
56
+ class KustoCommandFormatter {
57
+ actionAdded = false;
58
+ constructor(editor) {
59
+ this.editor = editor;
60
+ // selection also represents no selection - for example the event gets triggered when moving cursor from point
61
+ // a to point b. in the case start position will equal end position.
62
+ editor.onDidChangeCursorSelection(changeEvent => {
63
+ if (this.editor.getModel().getLanguageId() !== 'kusto') {
64
+ return;
65
+ }
66
+ // Theoretically you would expect this code to run only once in onDidCreateEditor.
67
+ // Turns out that onDidCreateEditor is fired before the IStandaloneEditor is completely created (it is emmited by
68
+ // the super ctor before the child ctor was able to fully run).
69
+ // Thus we don't have a key binding provided yet when onDidCreateEditor is run, which is essential to call addAction.
70
+ // By adding the action here in onDidChangeCursorSelection we're making sure that the editor has a key binding provider,
71
+ // and we just need to make sure that this happens only once.
72
+ if (!this.actionAdded) {
73
+ editor.addAction({
74
+ id: 'editor.action.kusto.formatCurrentCommand',
75
+ label: 'Format Command Under Cursor',
76
+ keybindings: [monaco.KeyMod.chord(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyK, monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyF)],
77
+ run: ed => {
78
+ editor.trigger('KustoCommandFormatter', 'editor.action.formatSelection', null);
79
+ },
80
+ contextMenuGroupId: '1_modification'
81
+ });
82
+ this.actionAdded = true;
83
+ }
31
84
  });
32
- LanguageServiceDefaultsImpl.prototype.setLanguageSettings = function (options) {
33
- this._languageSettings = options || Object.create(null);
34
- this._onDidChange.fire(this);
35
- };
36
- LanguageServiceDefaultsImpl.prototype.setMaximumWorkerIdleTime = function (value) {
37
- // doesn't fire an event since no
38
- // worker restart is required here
39
- this._workerMaxIdleTime = value;
40
- };
41
- LanguageServiceDefaultsImpl.prototype.getWorkerMaxIdleTime = function () {
42
- return this._workerMaxIdleTime;
43
- };
44
- return LanguageServiceDefaultsImpl;
45
- }());
46
- export { LanguageServiceDefaultsImpl };
47
- var defaultLanguageSettings = {
48
- includeControlCommands: true,
49
- newlineAfterPipe: true,
50
- openSuggestionDialogAfterPreviousSuggestionAccepted: true,
51
- useIntellisenseV2: true,
52
- useSemanticColorization: true,
53
- useTokenColorization: false,
54
- enableHover: true,
55
- formatter: {
56
- indentationSize: 4,
57
- pipeOperatorStyle: 'Smart',
58
- },
59
- syntaxErrorAsMarkDown: {
60
- enableSyntaxErrorAsMarkDown: false,
61
- },
62
- enableQueryWarnings: false,
63
- enableQuerySuggestions: false,
64
- disabledDiagnosticCodes: [],
65
- quickFixCodeActions: ['Change to'],
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Extending ICode editor to contain additional kusto-specific methods.
90
+ * note that the extend method needs to be called at least once to take affect, otherwise this here code is useless.
91
+ */
92
+ function extend(editor) {
93
+ const proto = Object.getPrototypeOf(editor);
94
+ proto.getCurrentCommandRange = function (cursorPosition) {
95
+ const zeroBasedCursorLineNumber = cursorPosition.lineNumber - 1;
96
+ const lines = this.getModel().getLinesContent();
97
+ let commandOrdinal = 0;
98
+ const linesWithCommandOrdinal = [];
99
+ for (let lineNumber = 0; lineNumber < lines.length; lineNumber++) {
100
+ let isEmptyLine = lines[lineNumber].trim() === '';
101
+ if (isEmptyLine) {
102
+ // increase commandCounter - we'll be starting a new command.
103
+ linesWithCommandOrdinal.push({
104
+ commandOrdinal: commandOrdinal++,
105
+ lineNumber
106
+ });
107
+ } else {
108
+ linesWithCommandOrdinal.push({
109
+ commandOrdinal: commandOrdinal,
110
+ lineNumber
111
+ });
112
+ }
113
+
114
+ // No need to keep scanning if we're past our line and we've seen an empty line.
115
+ if (lineNumber > zeroBasedCursorLineNumber && commandOrdinal > linesWithCommandOrdinal[zeroBasedCursorLineNumber].commandOrdinal) {
116
+ break;
117
+ }
118
+ }
119
+ const currentCommandOrdinal = linesWithCommandOrdinal[zeroBasedCursorLineNumber].commandOrdinal;
120
+ const currentCommandLines = linesWithCommandOrdinal.filter(line => line.commandOrdinal === currentCommandOrdinal);
121
+ const currentCommandStartLine = currentCommandLines[0].lineNumber + 1;
122
+ const currentCommandEndLine = currentCommandLines[currentCommandLines.length - 1].lineNumber + 1;
123
+
124
+ // End-column of 1 means no characters will be highlighted - since columns are 1-based in monaco apis.
125
+ // Start-column of 1 and End column of 2 means 1st character is selected.
126
+ // Thus if a line has n column and we need to provide n+1 so that the entire line will be highlighted.
127
+ const commandEndColumn = lines[currentCommandEndLine - 1].length + 1;
128
+ return new monaco.Range(currentCommandStartLine, 1, currentCommandEndLine, commandEndColumn);
129
+ };
130
+ }
131
+
132
+ var Emitter = monaco.Emitter;
133
+ monaco.IEvent;
134
+
135
+ // declare var require: <T>(moduleId: [string], callback: (module: T) => void) => void;
136
+
137
+ // --- Kusto configuration and defaults ---------
138
+
139
+ class LanguageServiceDefaultsImpl {
140
+ _onDidChange = new Emitter();
141
+ constructor(languageSettings) {
142
+ this.setLanguageSettings(languageSettings);
143
+ // default to never kill worker when idle.
144
+ // reason: when killing worker - schema gets lost. We transmit the schema back to main process when killing
145
+ // the worker, but in some extreme cases web worker runs out of memory while stringifying the schema.
146
+ // This stems from the fact that web workers have much more limited memory that the main process.
147
+ // An alternative solution (not currently implemented) is to just save the schema in the main process whenever calling
148
+ // setSchema. That way we don't need to stringify the schema on the worker side when killing the web worker.
149
+ this._workerMaxIdleTime = 0;
150
+ }
151
+ get onDidChange() {
152
+ return this._onDidChange.event;
153
+ }
154
+ get languageSettings() {
155
+ return this._languageSettings;
156
+ }
157
+ setLanguageSettings(options) {
158
+ this._languageSettings = options || Object.create(null);
159
+ this._onDidChange.fire(this);
160
+ }
161
+ setMaximumWorkerIdleTime(value) {
162
+ // doesn't fire an event since no
163
+ // worker restart is required here
164
+ this._workerMaxIdleTime = value;
165
+ }
166
+ getWorkerMaxIdleTime() {
167
+ return this._workerMaxIdleTime;
168
+ }
169
+ }
170
+ const defaultLanguageSettings = {
171
+ includeControlCommands: true,
172
+ newlineAfterPipe: true,
173
+ openSuggestionDialogAfterPreviousSuggestionAccepted: true,
174
+ useIntellisenseV2: true,
175
+ useSemanticColorization: true,
176
+ useTokenColorization: false,
177
+ enableHover: true,
178
+ formatter: {
179
+ indentationSize: 4,
180
+ pipeOperatorStyle: 'Smart'
181
+ },
182
+ syntaxErrorAsMarkDown: {
183
+ enableSyntaxErrorAsMarkDown: false
184
+ },
185
+ enableQueryWarnings: false,
186
+ enableQuerySuggestions: false,
187
+ disabledDiagnosticCodes: [],
188
+ quickFixCodeActions: ['Change to'],
189
+ enableQuickFixes: false
66
190
  };
67
191
  function getKustoWorker() {
68
- return new Promise(function (resolve, reject) {
69
- withMode(function (mode) {
70
- mode.getKustoWorker().then(resolve, reject);
71
- });
192
+ return new Promise((resolve, reject) => {
193
+ withMode(mode => {
194
+ mode.getKustoWorker().then(resolve, reject);
72
195
  });
196
+ });
73
197
  }
74
198
  function withMode(callback) {
75
- require(['vs/language/kusto/kustoMode'], callback);
199
+ import('./kustoMode.js').then(callback);
76
200
  }
77
- export function setupMonacoKusto(monacoInstance) {
78
- var kustoDefaults = new LanguageServiceDefaultsImpl(defaultLanguageSettings);
79
- function createAPI() {
80
- return {
81
- kustoDefaults: kustoDefaults,
82
- getKustoWorker: getKustoWorker,
83
- };
201
+ function setupMonacoKusto(monacoInstance) {
202
+ const kustoDefaults = new LanguageServiceDefaultsImpl(defaultLanguageSettings);
203
+ function createAPI() {
204
+ return {
205
+ kustoDefaults,
206
+ getKustoWorker
207
+ };
208
+ }
209
+ monacoInstance.languages.kusto = createAPI();
210
+ monacoInstance.languages.onLanguage('kusto', () => {
211
+ withMode(mode => mode.setupMode(kustoDefaults, monacoInstance));
212
+ });
213
+ monacoInstance.languages.register({
214
+ id: 'kusto',
215
+ extensions: ['.csl', '.kql']
216
+ });
217
+ monacoInstance.editor.defineTheme('kusto-light', {
218
+ base: 'vs',
219
+ inherit: true,
220
+ rules: [{
221
+ token: 'comment',
222
+ foreground: '008000'
223
+ },
224
+ // CommentToken Green
225
+ {
226
+ token: 'variable.predefined',
227
+ foreground: '800080'
228
+ },
229
+ // CalculatedColumnToken Purple
230
+ {
231
+ token: 'function',
232
+ foreground: '0000FF'
233
+ },
234
+ // FunctionNameToken Blue
235
+ {
236
+ token: 'operator.sql',
237
+ foreground: 'CC3700'
238
+ },
239
+ // _WAS_ OperatorToken OrangeRed, but wasn't accessible.
240
+ {
241
+ token: 'string',
242
+ foreground: 'B22222'
243
+ },
244
+ // StringLiteralToken Firebrick
245
+ {
246
+ token: 'operator.scss',
247
+ foreground: '0000FF'
248
+ },
249
+ // SubOperatorToken Blue
250
+ {
251
+ token: 'variable',
252
+ foreground: 'C71585'
253
+ },
254
+ // TableColumnToken MediumVioletRed
255
+ {
256
+ token: 'variable.parameter',
257
+ foreground: '9932CC'
258
+ },
259
+ // TableToken DarkOrchid
260
+ {
261
+ token: '',
262
+ foreground: '000000'
263
+ },
264
+ // UnknownToken, PlainTextToken Black
265
+ {
266
+ token: 'type',
267
+ foreground: '0000FF'
268
+ },
269
+ // DataTypeToken Blue
270
+ {
271
+ token: 'tag',
272
+ foreground: '0000FF'
273
+ },
274
+ // ControlCommandToken Blue
275
+ {
276
+ token: 'annotation',
277
+ foreground: '2B91AF'
278
+ },
279
+ // QueryParametersToken FF2B91AF
280
+ {
281
+ token: 'keyword',
282
+ foreground: '0000FF'
283
+ },
284
+ // CslCommandToken, PluginToken Blue
285
+ {
286
+ token: 'number',
287
+ foreground: '191970'
288
+ },
289
+ // LetVariablesToken MidnightBlue
290
+ {
291
+ token: 'annotation',
292
+ foreground: '9400D3'
293
+ },
294
+ // ClientDirectiveToken DarkViolet
295
+ {
296
+ token: 'invalid',
297
+ background: 'cd3131'
298
+ }],
299
+ colors: {}
300
+ });
301
+ monacoInstance.editor.defineTheme('kusto-dark', {
302
+ base: 'vs-dark',
303
+ inherit: true,
304
+ rules: [{
305
+ token: 'comment',
306
+ foreground: '608B4E'
307
+ },
308
+ // CommentToken Green
309
+ {
310
+ token: 'variable.predefined',
311
+ foreground: '4ec9b0'
312
+ },
313
+ // CalculatedColumnToken Purple
314
+ {
315
+ token: 'function',
316
+ foreground: 'dcdcaa'
317
+ },
318
+ // FunctionNameToken Blue
319
+ {
320
+ token: 'operator.sql',
321
+ foreground: '9cdcfe'
322
+ },
323
+ // OperatorToken OrangeRed
324
+ {
325
+ token: 'string',
326
+ foreground: 'ce9178'
327
+ },
328
+ // StringLiteralToken Firebrick
329
+ {
330
+ token: 'operator.scss',
331
+ foreground: '569cd6'
332
+ },
333
+ // SubOperatorToken Blue
334
+ {
335
+ token: 'variable',
336
+ foreground: '4ec9b0'
337
+ },
338
+ // TableColumnToken MediumVioletRed
339
+ {
340
+ token: 'variable.parameter',
341
+ foreground: 'c586c0'
342
+ },
343
+ // TableToken DarkOrchid
344
+ {
345
+ token: '',
346
+ foreground: 'd4d4d4'
347
+ },
348
+ // UnknownToken, PlainTextToken Black
349
+ {
350
+ token: 'type',
351
+ foreground: '569cd6'
352
+ },
353
+ // DataTypeToken Blue
354
+ {
355
+ token: 'tag',
356
+ foreground: '569cd6'
357
+ },
358
+ // ControlCommandToken Blue
359
+ {
360
+ token: 'annotation',
361
+ foreground: '9cdcfe'
362
+ },
363
+ // QueryParametersToken FF2B91AF
364
+ {
365
+ token: 'keyword',
366
+ foreground: '569cd6'
367
+ },
368
+ // CslCommandToken, PluginToken Blue
369
+ {
370
+ token: 'number',
371
+ foreground: 'd7ba7d'
372
+ },
373
+ // LetVariablesToken MidnightBlue
374
+ {
375
+ token: 'annotation',
376
+ foreground: 'b5cea8'
377
+ },
378
+ // ClientDirectiveToken DarkViolet
379
+ {
380
+ token: 'invalid',
381
+ background: 'cd3131'
382
+ }],
383
+ colors: {
384
+ // see: https://code.visualstudio.com/api/references/theme-color#editor-widget-colors
84
385
  }
85
- monacoInstance.languages.kusto = createAPI();
86
- monacoInstance.languages.onLanguage('kusto', function () {
87
- withMode(function (mode) { return mode.setupMode(kustoDefaults, monacoInstance); });
88
- });
89
- monacoInstance.languages.register({
90
- id: 'kusto',
91
- extensions: ['.csl', '.kql'],
92
- });
93
- // TODO: asked if there's a cleaner way to register an editor contribution. looks like monaco has an internal contribution registrar but it's no exposed in the API.
94
- // https://stackoverflow.com/questions/46700245/how-to-add-an-ieditorcontribution-to-monaco-editor
95
- var commandHighlighter;
96
- var commandFormatter;
97
- monacoInstance.editor.defineTheme('kusto-light', {
98
- base: 'vs',
99
- inherit: true,
100
- rules: [
101
- { token: 'comment', foreground: '008000' },
102
- { token: 'variable.predefined', foreground: '800080' },
103
- { token: 'function', foreground: '0000FF' },
104
- { token: 'operator.sql', foreground: 'CC3700' },
105
- { token: 'string', foreground: 'B22222' },
106
- { token: 'operator.scss', foreground: '0000FF' },
107
- { token: 'variable', foreground: 'C71585' },
108
- { token: 'variable.parameter', foreground: '9932CC' },
109
- { token: '', foreground: '000000' },
110
- { token: 'type', foreground: '0000FF' },
111
- { token: 'tag', foreground: '0000FF' },
112
- { token: 'annotation', foreground: '2B91AF' },
113
- { token: 'keyword', foreground: '0000FF' },
114
- { token: 'number', foreground: '191970' },
115
- { token: 'annotation', foreground: '9400D3' },
116
- { token: 'invalid', background: 'cd3131' },
117
- ],
118
- colors: {},
119
- });
120
- monacoInstance.editor.defineTheme('kusto-dark', {
121
- base: 'vs-dark',
122
- inherit: true,
123
- rules: [
124
- { token: 'comment', foreground: '608B4E' },
125
- { token: 'variable.predefined', foreground: '4ec9b0' },
126
- { token: 'function', foreground: 'dcdcaa' },
127
- { token: 'operator.sql', foreground: '9cdcfe' },
128
- { token: 'string', foreground: 'ce9178' },
129
- { token: 'operator.scss', foreground: '569cd6' },
130
- { token: 'variable', foreground: '4ec9b0' },
131
- { token: 'variable.parameter', foreground: 'c586c0' },
132
- { token: '', foreground: 'd4d4d4' },
133
- { token: 'type', foreground: '569cd6' },
134
- { token: 'tag', foreground: '569cd6' },
135
- { token: 'annotation', foreground: '9cdcfe' },
136
- { token: 'keyword', foreground: '569cd6' },
137
- { token: 'number', foreground: 'd7ba7d' },
138
- { token: 'annotation', foreground: 'b5cea8' },
139
- { token: 'invalid', background: 'cd3131' },
140
- ],
141
- colors: {
142
- // see: https://code.visualstudio.com/api/references/theme-color#editor-widget-colors
143
- },
144
- });
145
- monacoInstance.editor.defineTheme('kusto-dark2', {
146
- base: 'vs-dark',
147
- inherit: true,
148
- rules: [],
149
- colors: {
150
- // see: https://code.visualstudio.com/api/references/theme-color#editor-widget-colors
151
- 'editor.background': '#1B1A19',
152
- 'editorSuggestWidget.selectedBackground': '#004E8C',
153
- },
154
- });
155
- // Initialize kusto specific language features that don't currently have a natural way to extend using existing apis.
156
- // Most other language features are initialized in kustoMode.ts
157
- monacoInstance.editor.onDidCreateEditor(function (editor) {
158
- // hook up extension methods to editor.
159
- extend(editor);
160
- commandHighlighter = new KustoCommandHighlighter(editor);
161
- if (isStandaloneCodeEditor(editor)) {
162
- commandFormatter = new KustoCommandFormatter(editor);
386
+ });
387
+ monacoInstance.editor.defineTheme('kusto-dark2', {
388
+ base: 'vs-dark',
389
+ inherit: true,
390
+ rules: [],
391
+ colors: {
392
+ // see: https://code.visualstudio.com/api/references/theme-color#editor-widget-colors
393
+ 'editor.background': '#1B1A19',
394
+ // gray 200
395
+ 'editorSuggestWidget.selectedBackground': '#004E8C'
396
+ }
397
+ });
398
+
399
+ // Initialize kusto specific language features that don't currently have a natural way to extend using existing apis.
400
+ // Most other language features are initialized in kustoMode.ts
401
+ monacoInstance.editor.onDidCreateEditor(editor => {
402
+ // hook up extension methods to editor.
403
+ extend(editor);
404
+ new KustoCommandHighlighter(editor);
405
+ if (isStandaloneCodeEditor(editor)) {
406
+ new KustoCommandFormatter(editor);
407
+ }
408
+ triggerSuggestDialogWhenCompletionItemSelected(editor);
409
+ });
410
+ function triggerSuggestDialogWhenCompletionItemSelected(editor) {
411
+ editor.onDidChangeCursorSelection(event => {
412
+ // checking the condition inside the event makes sure we will stay up to date when kusto configuration changes at runtime.
413
+ if (kustoDefaults && kustoDefaults.languageSettings && kustoDefaults.languageSettings.openSuggestionDialogAfterPreviousSuggestionAccepted) {
414
+ var didAcceptSuggestion = event.source === 'snippet' && event.reason === monaco.editor.CursorChangeReason.NotSet;
415
+ // If the word at the current position is not null - meaning we did not add a space after completion.
416
+ // In this case we don't want to activate the eager mode, since it will display the current selected word..
417
+ if (!didAcceptSuggestion || editor.getModel().getWordAtPosition(event.selection.getPosition()) !== null) {
418
+ return;
163
419
  }
164
- triggerSuggestDialogWhenCompletionItemSelected(editor);
420
+ event.selection;
421
+ // OK so now we in a situation where we know a suggestion was selected and we want to trigger another one.
422
+ // the only problem is that the suggestion widget itself listens to this same event in order to know it needs to close.
423
+ // The only problem is that we're ahead in line, so we're triggering a suggest operation that will be shut down once
424
+ // the next callback is called. This is why we're waiting here - to let all the callbacks run synchronously and be
425
+ // the 'last' subscriber to run. Granted this is hacky, but until monaco provides a specific event for suggestions,
426
+ // this is the best we have.
427
+ setTimeout(() => editor.trigger('monaco-kusto', 'editor.action.triggerSuggest', {}), 10);
428
+ }
165
429
  });
166
- function triggerSuggestDialogWhenCompletionItemSelected(editor) {
167
- editor.onDidChangeCursorSelection(function (event) {
168
- // checking the condition inside the event makes sure we will stay up to date when kusto configuration changes at runtime.
169
- if (kustoDefaults &&
170
- kustoDefaults.languageSettings &&
171
- kustoDefaults.languageSettings.openSuggestionDialogAfterPreviousSuggestionAccepted) {
172
- var didAcceptSuggestion = event.source === 'snippet' && event.reason === monaco.editor.CursorChangeReason.NotSet;
173
- // If the word at the current position is not null - meaning we did not add a space after completion.
174
- // In this case we don't want to activate the eager mode, since it will display the current selected word..
175
- if (!didAcceptSuggestion ||
176
- editor.getModel().getWordAtPosition(event.selection.getPosition()) !== null) {
177
- return;
178
- }
179
- event.selection;
180
- // OK so now we in a situation where we know a suggestion was selected and we want to trigger another one.
181
- // the only problem is that the suggestion widget itself listens to this same event in order to know it needs to close.
182
- // The only problem is that we're ahead in line, so we're triggering a suggest operation that will be shut down once
183
- // the next callback is called. This is why we're waiting here - to let all the callbacks run synchronously and be
184
- // the 'last' subscriber to run. Granted this is hacky, but until monaco provides a specific event for suggestions,
185
- // this is the best we have.
186
- setTimeout(function () { return editor.trigger('monaco-kusto', 'editor.action.triggerSuggest', {}); }, 10);
187
- }
188
- });
189
- }
430
+ }
190
431
  }
191
432
  function isStandaloneCodeEditor(editor) {
192
- return editor.addAction !== undefined;
433
+ return editor.addAction !== undefined;
193
434
  }
435
+
194
436
  // --- Registration to monaco editor ---
195
437
  if (monaco.editor) {
196
- setupMonacoKusto(monaco);
438
+ setupMonacoKusto(monaco);
197
439
  }
440
+
441
+ export { LanguageServiceDefaultsImpl, setupMonacoKusto };
@@ -0,0 +1,23 @@
1
+ /// <reference types="../monaco" />
2
+ /// <reference types="monaco-editor-core/monaco" />
3
+ import type { LanguageServiceDefaultsImpl } from './monaco.contribution';
4
+ import type { KustoWorker } from './kustoWorker';
5
+ type Uri = monaco.Uri;
6
+ export declare class WorkerManager {
7
+ private _monacoInstance;
8
+ private _storedState;
9
+ private _defaults;
10
+ private _idleCheckInterval;
11
+ private _lastUsedTime;
12
+ private _configChangeListener;
13
+ private _worker;
14
+ private _client;
15
+ constructor(_monacoInstance: typeof monaco, defaults: LanguageServiceDefaultsImpl);
16
+ private _stopWorker;
17
+ private _saveStateAndStopWorker;
18
+ dispose(): void;
19
+ private _checkIfIdle;
20
+ private _getClient;
21
+ getLanguageServiceWorker(...resources: Uri[]): Promise<KustoWorker>;
22
+ }
23
+ export {};
@@ -0,0 +1,6 @@
1
+ /// <reference types="monaco-editor-core/monaco" />
2
+ export default class KustoCommandFormatter {
3
+ private editor;
4
+ private actionAdded;
5
+ constructor(editor: monaco.editor.IStandaloneCodeEditor);
6
+ }