@kusto/monaco-kusto 5.6.6 → 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.
- package/package.json +26 -16
- package/release/dev/commandFormatter.d.ts +6 -0
- package/release/dev/commandHighlighter.d.ts +20 -0
- package/release/dev/extendedEditor.d.ts +7 -0
- package/release/dev/kustoMode.d.ts +8 -0
- package/release/dev/kustoMode.js +1730 -3278
- package/release/dev/kustoWorker.d.ts +92 -0
- package/release/dev/kustoWorker.js +5663 -8534
- package/release/dev/languageFeatures.d.ts +91 -0
- package/release/dev/languageService/kustoLanguageService.d.ts +142 -0
- package/release/dev/languageService/kustoMonarchLanguageDefinition.d.ts +1 -0
- package/release/dev/languageService/renderInfo.d.ts +31 -0
- package/release/dev/languageService/schema.d.ts +144 -0
- package/release/dev/languageService/settings.d.ts +30 -0
- package/release/dev/main-24a15f15.js +1958 -0
- package/release/dev/monaco.contribution.d.ts +15 -0
- package/release/dev/monaco.contribution.js +462 -309
- package/release/dev/workerManager.d.ts +23 -0
- package/release/esm/commandFormatter.d.ts +6 -0
- package/release/esm/commandHighlighter.d.ts +20 -0
- package/release/esm/extendedEditor.d.ts +7 -0
- package/release/esm/kusto.worker.js +2224 -5
- package/release/esm/kustoMode.d.ts +8 -0
- package/release/esm/kustoMode.js +1120 -88
- package/release/esm/kustoWorker.d.ts +92 -0
- package/release/esm/languageFeatures.d.ts +91 -0
- package/release/esm/languageService/kustoLanguageService.d.ts +142 -0
- package/release/esm/languageService/kustoMonarchLanguageDefinition.d.ts +1 -0
- package/release/esm/languageService/renderInfo.d.ts +31 -0
- package/release/esm/languageService/schema.d.ts +144 -0
- package/release/esm/languageService/settings.d.ts +30 -0
- package/release/esm/monaco.contribution.d.ts +1 -0
- package/release/esm/monaco.contribution.js +424 -181
- package/release/esm/workerManager.d.ts +23 -0
- package/release/min/commandFormatter.d.ts +6 -0
- package/release/min/commandHighlighter.d.ts +20 -0
- package/release/min/extendedEditor.d.ts +7 -0
- package/release/min/kustoMode.d.ts +8 -0
- package/release/min/kustoMode.js +2 -11
- package/release/min/kustoWorker.d.ts +92 -0
- package/release/min/kustoWorker.js +10 -53
- package/release/min/languageFeatures.d.ts +91 -0
- package/release/min/languageService/kustoLanguageService.d.ts +142 -0
- package/release/min/languageService/kustoMonarchLanguageDefinition.d.ts +1 -0
- package/release/min/languageService/renderInfo.d.ts +31 -0
- package/release/min/languageService/schema.d.ts +144 -0
- package/release/min/languageService/settings.d.ts +30 -0
- package/release/min/main-1108181b.js +7 -0
- package/release/min/monaco.contribution.d.ts +1 -0
- package/release/min/monaco.contribution.js +2 -2
- package/release/min/monaco.d.ts +1 -319
- package/release/min/workerManager.d.ts +23 -0
- package/release/esm/_deps/lodash/lodash.js +0 -17209
- package/release/esm/_deps/vscode-languageserver-types/main.js +0 -1908
- package/release/esm/_deps/xregexp/xregexp-all.js +0 -4652
- package/release/esm/commandFormatter.js +0 -36
- package/release/esm/commandHighlighter.js +0 -51
- package/release/esm/extendedEditor.js +0 -38
- package/release/esm/kustoWorker.js +0 -245
- package/release/esm/languageFeatures.js +0 -1032
- package/release/esm/languageService/kustoLanguageService.js +0 -1912
- package/release/esm/languageService/kustoMonarchLanguageDefinition.js +0 -127
- package/release/esm/languageService/schema.js +0 -64
- package/release/esm/workerManager.js +0 -102
- /package/release/{esm/monaco.d.ts → monaco.d.ts} +0 -0
|
@@ -1,198 +1,441 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
|
67
190
|
};
|
|
68
191
|
function getKustoWorker() {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
});
|
|
192
|
+
return new Promise((resolve, reject) => {
|
|
193
|
+
withMode(mode => {
|
|
194
|
+
mode.getKustoWorker().then(resolve, reject);
|
|
73
195
|
});
|
|
196
|
+
});
|
|
74
197
|
}
|
|
75
198
|
function withMode(callback) {
|
|
76
|
-
|
|
199
|
+
import('./kustoMode.js').then(callback);
|
|
77
200
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
|
85
385
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
colors: {},
|
|
120
|
-
});
|
|
121
|
-
monacoInstance.editor.defineTheme('kusto-dark', {
|
|
122
|
-
base: 'vs-dark',
|
|
123
|
-
inherit: true,
|
|
124
|
-
rules: [
|
|
125
|
-
{ token: 'comment', foreground: '608B4E' },
|
|
126
|
-
{ token: 'variable.predefined', foreground: '4ec9b0' },
|
|
127
|
-
{ token: 'function', foreground: 'dcdcaa' },
|
|
128
|
-
{ token: 'operator.sql', foreground: '9cdcfe' },
|
|
129
|
-
{ token: 'string', foreground: 'ce9178' },
|
|
130
|
-
{ token: 'operator.scss', foreground: '569cd6' },
|
|
131
|
-
{ token: 'variable', foreground: '4ec9b0' },
|
|
132
|
-
{ token: 'variable.parameter', foreground: 'c586c0' },
|
|
133
|
-
{ token: '', foreground: 'd4d4d4' },
|
|
134
|
-
{ token: 'type', foreground: '569cd6' },
|
|
135
|
-
{ token: 'tag', foreground: '569cd6' },
|
|
136
|
-
{ token: 'annotation', foreground: '9cdcfe' },
|
|
137
|
-
{ token: 'keyword', foreground: '569cd6' },
|
|
138
|
-
{ token: 'number', foreground: 'd7ba7d' },
|
|
139
|
-
{ token: 'annotation', foreground: 'b5cea8' },
|
|
140
|
-
{ token: 'invalid', background: 'cd3131' },
|
|
141
|
-
],
|
|
142
|
-
colors: {
|
|
143
|
-
// see: https://code.visualstudio.com/api/references/theme-color#editor-widget-colors
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
monacoInstance.editor.defineTheme('kusto-dark2', {
|
|
147
|
-
base: 'vs-dark',
|
|
148
|
-
inherit: true,
|
|
149
|
-
rules: [],
|
|
150
|
-
colors: {
|
|
151
|
-
// see: https://code.visualstudio.com/api/references/theme-color#editor-widget-colors
|
|
152
|
-
'editor.background': '#1B1A19',
|
|
153
|
-
'editorSuggestWidget.selectedBackground': '#004E8C',
|
|
154
|
-
},
|
|
155
|
-
});
|
|
156
|
-
// Initialize kusto specific language features that don't currently have a natural way to extend using existing apis.
|
|
157
|
-
// Most other language features are initialized in kustoMode.ts
|
|
158
|
-
monacoInstance.editor.onDidCreateEditor(function (editor) {
|
|
159
|
-
// hook up extension methods to editor.
|
|
160
|
-
extend(editor);
|
|
161
|
-
commandHighlighter = new KustoCommandHighlighter(editor);
|
|
162
|
-
if (isStandaloneCodeEditor(editor)) {
|
|
163
|
-
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;
|
|
164
419
|
}
|
|
165
|
-
|
|
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
|
+
}
|
|
166
429
|
});
|
|
167
|
-
|
|
168
|
-
editor.onDidChangeCursorSelection(function (event) {
|
|
169
|
-
// checking the condition inside the event makes sure we will stay up to date when kusto configuration changes at runtime.
|
|
170
|
-
if (kustoDefaults &&
|
|
171
|
-
kustoDefaults.languageSettings &&
|
|
172
|
-
kustoDefaults.languageSettings.openSuggestionDialogAfterPreviousSuggestionAccepted) {
|
|
173
|
-
var didAcceptSuggestion = event.source === 'snippet' && event.reason === monaco.editor.CursorChangeReason.NotSet;
|
|
174
|
-
// If the word at the current position is not null - meaning we did not add a space after completion.
|
|
175
|
-
// In this case we don't want to activate the eager mode, since it will display the current selected word..
|
|
176
|
-
if (!didAcceptSuggestion ||
|
|
177
|
-
editor.getModel().getWordAtPosition(event.selection.getPosition()) !== null) {
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
event.selection;
|
|
181
|
-
// OK so now we in a situation where we know a suggestion was selected and we want to trigger another one.
|
|
182
|
-
// the only problem is that the suggestion widget itself listens to this same event in order to know it needs to close.
|
|
183
|
-
// The only problem is that we're ahead in line, so we're triggering a suggest operation that will be shut down once
|
|
184
|
-
// the next callback is called. This is why we're waiting here - to let all the callbacks run synchronously and be
|
|
185
|
-
// the 'last' subscriber to run. Granted this is hacky, but until monaco provides a specific event for suggestions,
|
|
186
|
-
// this is the best we have.
|
|
187
|
-
setTimeout(function () { return editor.trigger('monaco-kusto', 'editor.action.triggerSuggest', {}); }, 10);
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
}
|
|
430
|
+
}
|
|
191
431
|
}
|
|
192
432
|
function isStandaloneCodeEditor(editor) {
|
|
193
|
-
|
|
433
|
+
return editor.addAction !== undefined;
|
|
194
434
|
}
|
|
435
|
+
|
|
195
436
|
// --- Registration to monaco editor ---
|
|
196
437
|
if (monaco.editor) {
|
|
197
|
-
|
|
438
|
+
setupMonacoKusto(monaco);
|
|
198
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 {};
|