@kusto/monaco-kusto 3.2.4 → 3.2.7
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 +88 -88
- package/release/dev/kustoMode.js +1070 -1070
- package/release/dev/kustoWorker.js +1856 -1833
- package/release/dev/monaco.contribution.js +310 -306
- package/release/esm/commandFormatter.js +32 -32
- package/release/esm/commandHighlighter.js +44 -44
- package/release/esm/extendedEditor.js +38 -38
- package/release/esm/kusto.worker.js +8 -8
- package/release/esm/kustoMode.js +98 -98
- package/release/esm/kustoWorker.js +199 -199
- package/release/esm/languageFeatures.js +778 -778
- package/release/esm/languageService/kustoLanguageService.js +1585 -1562
- package/release/esm/languageService/kustoMonarchLanguageDefinition.js +76 -76
- package/release/esm/languageService/schema.js +64 -64
- package/release/esm/monaco.contribution.d.ts +12 -12
- package/release/esm/monaco.contribution.js +180 -176
- package/release/esm/monaco.d.ts +232 -224
- package/release/esm/workerManager.js +101 -101
- package/release/min/kustoMode.js +1 -1
- package/release/min/kustoWorker.js +2 -2
- package/release/min/monaco.contribution.d.ts +12 -12
- package/release/min/monaco.contribution.js +2 -2
- package/release/min/monaco.d.ts +232 -224
- package/scripts/bundle.js +65 -65
- package/scripts/release.js +25 -25
|
@@ -1,310 +1,314 @@
|
|
|
1
|
-
define('vs/language/kusto/commandHighlighter',["require", "exports"], function (require, exports) {
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
/**
|
|
5
|
-
* Highlights the command that surround cursor location
|
|
6
|
-
*/
|
|
7
|
-
var KustoCommandHighlighter = /** @class */ (function () {
|
|
8
|
-
/**
|
|
9
|
-
* Register to cursor movement and seleciton events.
|
|
10
|
-
* @param editor monaco editor instance
|
|
11
|
-
*/
|
|
12
|
-
function KustoCommandHighlighter(editor) {
|
|
13
|
-
var _this = this;
|
|
14
|
-
this.editor = editor;
|
|
15
|
-
this.disposables = [];
|
|
16
|
-
this.decorations = [];
|
|
17
|
-
// 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.
|
|
18
|
-
// This case is counted as a 0-length selection starting and ending on the cursor position.
|
|
19
|
-
this.editor.onDidChangeCursorSelection(function (changeEvent) {
|
|
20
|
-
_this.highlightCommandUnderCursor(changeEvent);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
KustoCommandHighlighter.prototype.getId = function () {
|
|
24
|
-
return KustoCommandHighlighter.ID;
|
|
25
|
-
};
|
|
26
|
-
KustoCommandHighlighter.prototype.dispose = function () {
|
|
27
|
-
this.disposables.forEach(function (d) { return d.dispose(); });
|
|
28
|
-
};
|
|
29
|
-
KustoCommandHighlighter.prototype.highlightCommandUnderCursor = function (changeEvent) {
|
|
30
|
-
// Looks like the user selected a bunch of text. we don't want to highlight the entire command in this case - since highlighting
|
|
31
|
-
// the text is more helpful.
|
|
32
|
-
if (!changeEvent.selection.isEmpty()) {
|
|
33
|
-
this.decorations = this.editor.deltaDecorations(this.decorations, []);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
var commandRange = this.editor.getCurrentCommandRange(changeEvent.selection.getStartPosition());
|
|
37
|
-
var decorations = [{
|
|
38
|
-
range: commandRange,
|
|
39
|
-
options: KustoCommandHighlighter.CURRENT_COMMAND_HIGHLIGHT
|
|
40
|
-
}];
|
|
41
|
-
this.decorations = this.editor.deltaDecorations(this.decorations, decorations);
|
|
42
|
-
};
|
|
43
|
-
KustoCommandHighlighter.ID = 'editor.contrib.kustoCommandHighliter';
|
|
44
|
-
KustoCommandHighlighter.CURRENT_COMMAND_HIGHLIGHT = { className: 'selectionHighlight' };
|
|
45
|
-
return KustoCommandHighlighter;
|
|
46
|
-
}());
|
|
47
|
-
exports.default = KustoCommandHighlighter;
|
|
48
|
-
});
|
|
1
|
+
define('vs/language/kusto/commandHighlighter',["require", "exports"], function (require, exports) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
/**
|
|
5
|
+
* Highlights the command that surround cursor location
|
|
6
|
+
*/
|
|
7
|
+
var KustoCommandHighlighter = /** @class */ (function () {
|
|
8
|
+
/**
|
|
9
|
+
* Register to cursor movement and seleciton events.
|
|
10
|
+
* @param editor monaco editor instance
|
|
11
|
+
*/
|
|
12
|
+
function KustoCommandHighlighter(editor) {
|
|
13
|
+
var _this = this;
|
|
14
|
+
this.editor = editor;
|
|
15
|
+
this.disposables = [];
|
|
16
|
+
this.decorations = [];
|
|
17
|
+
// 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.
|
|
18
|
+
// This case is counted as a 0-length selection starting and ending on the cursor position.
|
|
19
|
+
this.editor.onDidChangeCursorSelection(function (changeEvent) {
|
|
20
|
+
_this.highlightCommandUnderCursor(changeEvent);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
KustoCommandHighlighter.prototype.getId = function () {
|
|
24
|
+
return KustoCommandHighlighter.ID;
|
|
25
|
+
};
|
|
26
|
+
KustoCommandHighlighter.prototype.dispose = function () {
|
|
27
|
+
this.disposables.forEach(function (d) { return d.dispose(); });
|
|
28
|
+
};
|
|
29
|
+
KustoCommandHighlighter.prototype.highlightCommandUnderCursor = function (changeEvent) {
|
|
30
|
+
// Looks like the user selected a bunch of text. we don't want to highlight the entire command in this case - since highlighting
|
|
31
|
+
// the text is more helpful.
|
|
32
|
+
if (!changeEvent.selection.isEmpty()) {
|
|
33
|
+
this.decorations = this.editor.deltaDecorations(this.decorations, []);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
var commandRange = this.editor.getCurrentCommandRange(changeEvent.selection.getStartPosition());
|
|
37
|
+
var decorations = [{
|
|
38
|
+
range: commandRange,
|
|
39
|
+
options: KustoCommandHighlighter.CURRENT_COMMAND_HIGHLIGHT
|
|
40
|
+
}];
|
|
41
|
+
this.decorations = this.editor.deltaDecorations(this.decorations, decorations);
|
|
42
|
+
};
|
|
43
|
+
KustoCommandHighlighter.ID = 'editor.contrib.kustoCommandHighliter';
|
|
44
|
+
KustoCommandHighlighter.CURRENT_COMMAND_HIGHLIGHT = { className: 'selectionHighlight' };
|
|
45
|
+
return KustoCommandHighlighter;
|
|
46
|
+
}());
|
|
47
|
+
exports.default = KustoCommandHighlighter;
|
|
48
|
+
});
|
|
49
49
|
|
|
50
|
-
define('vs/language/kusto/commandFormatter',["require", "exports"], function (require, exports) {
|
|
51
|
-
"use strict";
|
|
52
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
var KustoCommandFormatter = /** @class */ (function () {
|
|
54
|
-
function KustoCommandFormatter(editor) {
|
|
55
|
-
var _this = this;
|
|
56
|
-
this.editor = editor;
|
|
57
|
-
this.actionAdded = false;
|
|
58
|
-
// selection also represents no selection - for example the event gets triggered when moving cursor from point
|
|
59
|
-
// a to point b. in the case start position will equal end position.
|
|
60
|
-
editor.onDidChangeCursorSelection(function (changeEvent) {
|
|
61
|
-
_this.cursorPosition = changeEvent.selection.getStartPosition();
|
|
62
|
-
// Theoretically you would expect this code to run only once in onDidCreateEditor.
|
|
63
|
-
// Turns out that onDidCreateEditor is fired before the IStandaloneEditor is completely created (it is emmited by
|
|
64
|
-
// the super ctor before the child ctor was able to fully run).
|
|
65
|
-
// Thus we don't have a key binding provided yet when onDidCreateEditor is run, which is essential to call addAction.
|
|
66
|
-
// By adding the action here in onDidChangeCursorSelection we're making sure that the editor has a key binding provider,
|
|
67
|
-
// and we just need to make sure that this happens only once.
|
|
68
|
-
if (!_this.actionAdded) {
|
|
69
|
-
editor.addAction({
|
|
70
|
-
id: 'editor.action.kusto.formatCurrentCommand',
|
|
71
|
-
label: 'Format Command Under Cursor',
|
|
72
|
-
keybindings: [monaco.KeyMod.chord(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_K, monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_F)],
|
|
73
|
-
run: function (ed) {
|
|
74
|
-
editor.trigger('KustoCommandFormatter', 'editor.action.formatSelection', null);
|
|
75
|
-
},
|
|
76
|
-
contextMenuGroupId: '1_modification'
|
|
77
|
-
});
|
|
78
|
-
_this.actionAdded = true;
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
return KustoCommandFormatter;
|
|
83
|
-
}());
|
|
84
|
-
exports.default = KustoCommandFormatter;
|
|
85
|
-
});
|
|
50
|
+
define('vs/language/kusto/commandFormatter',["require", "exports"], function (require, exports) {
|
|
51
|
+
"use strict";
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
var KustoCommandFormatter = /** @class */ (function () {
|
|
54
|
+
function KustoCommandFormatter(editor) {
|
|
55
|
+
var _this = this;
|
|
56
|
+
this.editor = editor;
|
|
57
|
+
this.actionAdded = false;
|
|
58
|
+
// selection also represents no selection - for example the event gets triggered when moving cursor from point
|
|
59
|
+
// a to point b. in the case start position will equal end position.
|
|
60
|
+
editor.onDidChangeCursorSelection(function (changeEvent) {
|
|
61
|
+
_this.cursorPosition = changeEvent.selection.getStartPosition();
|
|
62
|
+
// Theoretically you would expect this code to run only once in onDidCreateEditor.
|
|
63
|
+
// Turns out that onDidCreateEditor is fired before the IStandaloneEditor is completely created (it is emmited by
|
|
64
|
+
// the super ctor before the child ctor was able to fully run).
|
|
65
|
+
// Thus we don't have a key binding provided yet when onDidCreateEditor is run, which is essential to call addAction.
|
|
66
|
+
// By adding the action here in onDidChangeCursorSelection we're making sure that the editor has a key binding provider,
|
|
67
|
+
// and we just need to make sure that this happens only once.
|
|
68
|
+
if (!_this.actionAdded) {
|
|
69
|
+
editor.addAction({
|
|
70
|
+
id: 'editor.action.kusto.formatCurrentCommand',
|
|
71
|
+
label: 'Format Command Under Cursor',
|
|
72
|
+
keybindings: [monaco.KeyMod.chord(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_K, monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_F)],
|
|
73
|
+
run: function (ed) {
|
|
74
|
+
editor.trigger('KustoCommandFormatter', 'editor.action.formatSelection', null);
|
|
75
|
+
},
|
|
76
|
+
contextMenuGroupId: '1_modification'
|
|
77
|
+
});
|
|
78
|
+
_this.actionAdded = true;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return KustoCommandFormatter;
|
|
83
|
+
}());
|
|
84
|
+
exports.default = KustoCommandFormatter;
|
|
85
|
+
});
|
|
86
86
|
|
|
87
|
-
/// <reference path="../node_modules/monaco-editor-core/monaco.d.ts" />
|
|
88
|
-
define('vs/language/kusto/extendedEditor',["require", "exports"], function (require, exports) {
|
|
89
|
-
"use strict";
|
|
90
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
91
|
-
exports.extend = void 0;
|
|
92
|
-
/**
|
|
93
|
-
* Extending ICode editor to contain additional kusto-speicifc methods.
|
|
94
|
-
* note that the extend method needs to be called at least once to take affect, otherwise this here code is useless.
|
|
95
|
-
*/
|
|
96
|
-
function extend(editor) {
|
|
97
|
-
var proto = Object.getPrototypeOf(editor);
|
|
98
|
-
proto.getCurrentCommandRange = function (cursorPosition) {
|
|
99
|
-
var editor = this;
|
|
100
|
-
var zeroBasedCursorLineNumber = cursorPosition.lineNumber - 1;
|
|
101
|
-
var lines = this.getModel().getLinesContent();
|
|
102
|
-
var commandOrdinal = 0;
|
|
103
|
-
var linesWithCommandOrdinal = [];
|
|
104
|
-
for (var lineNumber = 0; lineNumber < lines.length; lineNumber++) {
|
|
105
|
-
var isEmptyLine = lines[lineNumber].trim() === '';
|
|
106
|
-
if (isEmptyLine) {
|
|
107
|
-
// increase commandCounter - we'll be starting a new command.
|
|
108
|
-
linesWithCommandOrdinal.push({ commandOrdinal: commandOrdinal++, lineNumber: lineNumber });
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
linesWithCommandOrdinal.push({ commandOrdinal: commandOrdinal, lineNumber: lineNumber });
|
|
112
|
-
}
|
|
113
|
-
// No need to keep scanning if we're past our line and we've seen an empty line.
|
|
114
|
-
if (lineNumber > zeroBasedCursorLineNumber && commandOrdinal > linesWithCommandOrdinal[zeroBasedCursorLineNumber].commandOrdinal) {
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
var currentCommandOrdinal = linesWithCommandOrdinal[zeroBasedCursorLineNumber].commandOrdinal;
|
|
119
|
-
var currentCommandLines = linesWithCommandOrdinal.filter(function (line) { return line.commandOrdinal === currentCommandOrdinal; });
|
|
120
|
-
var currentCommandStartLine = currentCommandLines[0].lineNumber + 1;
|
|
121
|
-
var currentCommandEndLine = currentCommandLines[currentCommandLines.length - 1].lineNumber + 1;
|
|
122
|
-
// End-column of 1 means no characters will be highlighted - since columns are 1-based in monaco apis.
|
|
123
|
-
// Start-column of 1 and End column of 2 means 1st character is selected.
|
|
124
|
-
// Thus if a line has n column and we need to provide n+1 so that the entire line will be highlighted.
|
|
125
|
-
var commandEndColumn = lines[currentCommandEndLine - 1].length + 1;
|
|
126
|
-
return new monaco.Range(currentCommandStartLine, 1, currentCommandEndLine, commandEndColumn);
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
exports.extend = extend;
|
|
130
|
-
});
|
|
87
|
+
/// <reference path="../node_modules/monaco-editor-core/monaco.d.ts" />
|
|
88
|
+
define('vs/language/kusto/extendedEditor',["require", "exports"], function (require, exports) {
|
|
89
|
+
"use strict";
|
|
90
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
91
|
+
exports.extend = void 0;
|
|
92
|
+
/**
|
|
93
|
+
* Extending ICode editor to contain additional kusto-speicifc methods.
|
|
94
|
+
* note that the extend method needs to be called at least once to take affect, otherwise this here code is useless.
|
|
95
|
+
*/
|
|
96
|
+
function extend(editor) {
|
|
97
|
+
var proto = Object.getPrototypeOf(editor);
|
|
98
|
+
proto.getCurrentCommandRange = function (cursorPosition) {
|
|
99
|
+
var editor = this;
|
|
100
|
+
var zeroBasedCursorLineNumber = cursorPosition.lineNumber - 1;
|
|
101
|
+
var lines = this.getModel().getLinesContent();
|
|
102
|
+
var commandOrdinal = 0;
|
|
103
|
+
var linesWithCommandOrdinal = [];
|
|
104
|
+
for (var lineNumber = 0; lineNumber < lines.length; lineNumber++) {
|
|
105
|
+
var isEmptyLine = lines[lineNumber].trim() === '';
|
|
106
|
+
if (isEmptyLine) {
|
|
107
|
+
// increase commandCounter - we'll be starting a new command.
|
|
108
|
+
linesWithCommandOrdinal.push({ commandOrdinal: commandOrdinal++, lineNumber: lineNumber });
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
linesWithCommandOrdinal.push({ commandOrdinal: commandOrdinal, lineNumber: lineNumber });
|
|
112
|
+
}
|
|
113
|
+
// No need to keep scanning if we're past our line and we've seen an empty line.
|
|
114
|
+
if (lineNumber > zeroBasedCursorLineNumber && commandOrdinal > linesWithCommandOrdinal[zeroBasedCursorLineNumber].commandOrdinal) {
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
var currentCommandOrdinal = linesWithCommandOrdinal[zeroBasedCursorLineNumber].commandOrdinal;
|
|
119
|
+
var currentCommandLines = linesWithCommandOrdinal.filter(function (line) { return line.commandOrdinal === currentCommandOrdinal; });
|
|
120
|
+
var currentCommandStartLine = currentCommandLines[0].lineNumber + 1;
|
|
121
|
+
var currentCommandEndLine = currentCommandLines[currentCommandLines.length - 1].lineNumber + 1;
|
|
122
|
+
// End-column of 1 means no characters will be highlighted - since columns are 1-based in monaco apis.
|
|
123
|
+
// Start-column of 1 and End column of 2 means 1st character is selected.
|
|
124
|
+
// Thus if a line has n column and we need to provide n+1 so that the entire line will be highlighted.
|
|
125
|
+
var commandEndColumn = lines[currentCommandEndLine - 1].length + 1;
|
|
126
|
+
return new monaco.Range(currentCommandStartLine, 1, currentCommandEndLine, commandEndColumn);
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
exports.extend = extend;
|
|
130
|
+
});
|
|
131
131
|
|
|
132
|
-
define('vs/language/kusto/monaco.contribution',["require", "exports", "./commandHighlighter", "./commandFormatter", "./extendedEditor"], function (require, exports, commandHighlighter_1, commandFormatter_1, extendedEditor_1) {
|
|
133
|
-
"use strict";
|
|
134
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
135
|
-
exports.LanguageServiceDefaultsImpl = void 0;
|
|
136
|
-
var Emitter = monaco.Emitter;
|
|
137
|
-
// --- Kusto configuration and defaults ---------
|
|
138
|
-
var LanguageServiceDefaultsImpl = /** @class */ (function () {
|
|
139
|
-
function LanguageServiceDefaultsImpl(languageSettings) {
|
|
140
|
-
this._onDidChange = new Emitter();
|
|
141
|
-
this.setLanguageSettings(languageSettings);
|
|
142
|
-
// default to never kill worker when idle.
|
|
143
|
-
// reason: when killing worker - schema gets lost. We transmit the schema back to main process when killing
|
|
144
|
-
// the worker, but in some extreme cases web worker runs out of memory while stringifying the schema.
|
|
145
|
-
// This stems from the fact that web workers have much more limited memory that the main process.
|
|
146
|
-
// An alternative solution (not currently implemented) is to just save the schema in the main process whenever calling
|
|
147
|
-
// setSchema. That way we don't need to stringify the schema on the worker side when killing the web worker.
|
|
148
|
-
this._workerMaxIdleTime = 0;
|
|
149
|
-
}
|
|
150
|
-
Object.defineProperty(LanguageServiceDefaultsImpl.prototype, "onDidChange", {
|
|
151
|
-
get: function () {
|
|
152
|
-
return this._onDidChange.event;
|
|
153
|
-
},
|
|
154
|
-
enumerable: false,
|
|
155
|
-
configurable: true
|
|
156
|
-
});
|
|
157
|
-
Object.defineProperty(LanguageServiceDefaultsImpl.prototype, "languageSettings", {
|
|
158
|
-
get: function () {
|
|
159
|
-
return this._languageSettings;
|
|
160
|
-
},
|
|
161
|
-
enumerable: false,
|
|
162
|
-
configurable: true
|
|
163
|
-
});
|
|
164
|
-
LanguageServiceDefaultsImpl.prototype.setLanguageSettings = function (options) {
|
|
165
|
-
this._languageSettings = options || Object.create(null);
|
|
166
|
-
this._onDidChange.fire(this);
|
|
167
|
-
};
|
|
168
|
-
LanguageServiceDefaultsImpl.prototype.setMaximumWorkerIdleTime = function (value) {
|
|
169
|
-
// doesn't fire an event since no
|
|
170
|
-
// worker restart is required here
|
|
171
|
-
this._workerMaxIdleTime = value;
|
|
172
|
-
};
|
|
173
|
-
LanguageServiceDefaultsImpl.prototype.getWorkerMaxIdleTime = function () {
|
|
174
|
-
return this._workerMaxIdleTime;
|
|
175
|
-
};
|
|
176
|
-
return LanguageServiceDefaultsImpl;
|
|
177
|
-
}());
|
|
178
|
-
exports.LanguageServiceDefaultsImpl = LanguageServiceDefaultsImpl;
|
|
179
|
-
var defaultLanguageSettings = {
|
|
180
|
-
includeControlCommands: true,
|
|
181
|
-
newlineAfterPipe: true,
|
|
182
|
-
openSuggestionDialogAfterPreviousSuggestionAccepted: true,
|
|
183
|
-
useIntellisenseV2: true,
|
|
184
|
-
useSemanticColorization: true,
|
|
185
|
-
useTokenColorization: true,
|
|
186
|
-
enableHover: true,
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
monaco
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
{ token: '
|
|
228
|
-
{ token: '
|
|
229
|
-
{ token: '
|
|
230
|
-
{ token: '
|
|
231
|
-
{ token: '', foreground: '
|
|
232
|
-
{ token: '
|
|
233
|
-
{ token: '
|
|
234
|
-
{ token: '
|
|
235
|
-
{ token: '
|
|
236
|
-
{ token: '
|
|
237
|
-
{ token: '
|
|
238
|
-
{ token: '
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
{ token: '
|
|
251
|
-
{ token: '
|
|
252
|
-
{ token: '
|
|
253
|
-
{ token: '
|
|
254
|
-
{ token: '', foreground: '
|
|
255
|
-
{ token: '
|
|
256
|
-
{ token: '
|
|
257
|
-
{ token: '
|
|
258
|
-
{ token: '
|
|
259
|
-
{ token: '
|
|
260
|
-
{ token: '
|
|
261
|
-
{ token: '
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
event.
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
//
|
|
300
|
-
//
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
}
|
|
132
|
+
define('vs/language/kusto/monaco.contribution',["require", "exports", "./commandHighlighter", "./commandFormatter", "./extendedEditor"], function (require, exports, commandHighlighter_1, commandFormatter_1, extendedEditor_1) {
|
|
133
|
+
"use strict";
|
|
134
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
135
|
+
exports.LanguageServiceDefaultsImpl = void 0;
|
|
136
|
+
var Emitter = monaco.Emitter;
|
|
137
|
+
// --- Kusto configuration and defaults ---------
|
|
138
|
+
var LanguageServiceDefaultsImpl = /** @class */ (function () {
|
|
139
|
+
function LanguageServiceDefaultsImpl(languageSettings) {
|
|
140
|
+
this._onDidChange = new Emitter();
|
|
141
|
+
this.setLanguageSettings(languageSettings);
|
|
142
|
+
// default to never kill worker when idle.
|
|
143
|
+
// reason: when killing worker - schema gets lost. We transmit the schema back to main process when killing
|
|
144
|
+
// the worker, but in some extreme cases web worker runs out of memory while stringifying the schema.
|
|
145
|
+
// This stems from the fact that web workers have much more limited memory that the main process.
|
|
146
|
+
// An alternative solution (not currently implemented) is to just save the schema in the main process whenever calling
|
|
147
|
+
// setSchema. That way we don't need to stringify the schema on the worker side when killing the web worker.
|
|
148
|
+
this._workerMaxIdleTime = 0;
|
|
149
|
+
}
|
|
150
|
+
Object.defineProperty(LanguageServiceDefaultsImpl.prototype, "onDidChange", {
|
|
151
|
+
get: function () {
|
|
152
|
+
return this._onDidChange.event;
|
|
153
|
+
},
|
|
154
|
+
enumerable: false,
|
|
155
|
+
configurable: true
|
|
156
|
+
});
|
|
157
|
+
Object.defineProperty(LanguageServiceDefaultsImpl.prototype, "languageSettings", {
|
|
158
|
+
get: function () {
|
|
159
|
+
return this._languageSettings;
|
|
160
|
+
},
|
|
161
|
+
enumerable: false,
|
|
162
|
+
configurable: true
|
|
163
|
+
});
|
|
164
|
+
LanguageServiceDefaultsImpl.prototype.setLanguageSettings = function (options) {
|
|
165
|
+
this._languageSettings = options || Object.create(null);
|
|
166
|
+
this._onDidChange.fire(this);
|
|
167
|
+
};
|
|
168
|
+
LanguageServiceDefaultsImpl.prototype.setMaximumWorkerIdleTime = function (value) {
|
|
169
|
+
// doesn't fire an event since no
|
|
170
|
+
// worker restart is required here
|
|
171
|
+
this._workerMaxIdleTime = value;
|
|
172
|
+
};
|
|
173
|
+
LanguageServiceDefaultsImpl.prototype.getWorkerMaxIdleTime = function () {
|
|
174
|
+
return this._workerMaxIdleTime;
|
|
175
|
+
};
|
|
176
|
+
return LanguageServiceDefaultsImpl;
|
|
177
|
+
}());
|
|
178
|
+
exports.LanguageServiceDefaultsImpl = LanguageServiceDefaultsImpl;
|
|
179
|
+
var defaultLanguageSettings = {
|
|
180
|
+
includeControlCommands: true,
|
|
181
|
+
newlineAfterPipe: true,
|
|
182
|
+
openSuggestionDialogAfterPreviousSuggestionAccepted: true,
|
|
183
|
+
useIntellisenseV2: true,
|
|
184
|
+
useSemanticColorization: true,
|
|
185
|
+
useTokenColorization: true,
|
|
186
|
+
enableHover: true,
|
|
187
|
+
formatter: {
|
|
188
|
+
indentationSize: 4,
|
|
189
|
+
pipeOperatorStyle: 'Smart'
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
var kustoDefaults = new LanguageServiceDefaultsImpl(defaultLanguageSettings);
|
|
193
|
+
function getKustoWorker() {
|
|
194
|
+
return new Promise(function (resolve, reject) {
|
|
195
|
+
withMode(function (mode) {
|
|
196
|
+
mode.getKustoWorker().then(resolve, reject);
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
// Export API
|
|
201
|
+
function createAPI() {
|
|
202
|
+
return {
|
|
203
|
+
kustoDefaults: kustoDefaults,
|
|
204
|
+
getKustoWorker: getKustoWorker,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
monaco.languages.kusto = createAPI();
|
|
208
|
+
// --- Registration to monaco editor ---
|
|
209
|
+
function withMode(callback) {
|
|
210
|
+
require(['vs/language/kusto/kustoMode'], callback);
|
|
211
|
+
}
|
|
212
|
+
monaco.languages.onLanguage('kusto', function () {
|
|
213
|
+
withMode(function (mode) { return mode.setupMode(kustoDefaults); });
|
|
214
|
+
});
|
|
215
|
+
monaco.languages.register({
|
|
216
|
+
id: 'kusto',
|
|
217
|
+
extensions: ['.csl', '.kql'],
|
|
218
|
+
});
|
|
219
|
+
// TODO: asked if there's a cleaner way to register an editor contribution. looks like monaco has an internal contribution regstrar but it's no exposed in the API.
|
|
220
|
+
// https://stackoverflow.com/questions/46700245/how-to-add-an-ieditorcontribution-to-monaco-editor
|
|
221
|
+
var commandHighlighter;
|
|
222
|
+
var commandFormatter;
|
|
223
|
+
monaco.editor.defineTheme('kusto-light', {
|
|
224
|
+
base: 'vs',
|
|
225
|
+
inherit: true,
|
|
226
|
+
rules: [
|
|
227
|
+
{ token: 'comment', foreground: '008000' },
|
|
228
|
+
{ token: 'variable.predefined', foreground: '800080' },
|
|
229
|
+
{ token: 'function', foreground: '0000FF' },
|
|
230
|
+
{ token: 'operator.sql', foreground: 'CC3700' },
|
|
231
|
+
{ token: 'string', foreground: 'B22222' },
|
|
232
|
+
{ token: 'operator.scss', foreground: '0000FF' },
|
|
233
|
+
{ token: 'variable', foreground: 'C71585' },
|
|
234
|
+
{ token: 'variable.parameter', foreground: '9932CC' },
|
|
235
|
+
{ token: '', foreground: '000000' },
|
|
236
|
+
{ token: 'type', foreground: '0000FF' },
|
|
237
|
+
{ token: 'tag', foreground: '0000FF' },
|
|
238
|
+
{ token: 'annotation', foreground: '2B91AF' },
|
|
239
|
+
{ token: 'keyword', foreground: '0000FF' },
|
|
240
|
+
{ token: 'number', foreground: '191970' },
|
|
241
|
+
{ token: 'annotation', foreground: '9400D3' },
|
|
242
|
+
{ token: 'invalid', background: 'cd3131' },
|
|
243
|
+
],
|
|
244
|
+
colors: {},
|
|
245
|
+
});
|
|
246
|
+
monaco.editor.defineTheme('kusto-dark', {
|
|
247
|
+
base: 'vs-dark',
|
|
248
|
+
inherit: true,
|
|
249
|
+
rules: [
|
|
250
|
+
{ token: 'comment', foreground: '608B4E' },
|
|
251
|
+
{ token: 'variable.predefined', foreground: '4ec9b0' },
|
|
252
|
+
{ token: 'function', foreground: 'dcdcaa' },
|
|
253
|
+
{ token: 'operator.sql', foreground: '9cdcfe' },
|
|
254
|
+
{ token: 'string', foreground: 'ce9178' },
|
|
255
|
+
{ token: 'operator.scss', foreground: '569cd6' },
|
|
256
|
+
{ token: 'variable', foreground: '4ec9b0' },
|
|
257
|
+
{ token: 'variable.parameter', foreground: 'c586c0' },
|
|
258
|
+
{ token: '', foreground: 'd4d4d4' },
|
|
259
|
+
{ token: 'type', foreground: '569cd6' },
|
|
260
|
+
{ token: 'tag', foreground: '569cd6' },
|
|
261
|
+
{ token: 'annotation', foreground: '9cdcfe' },
|
|
262
|
+
{ token: 'keyword', foreground: '569cd6' },
|
|
263
|
+
{ token: 'number', foreground: 'd7ba7d' },
|
|
264
|
+
{ token: 'annotation', foreground: 'b5cea8' },
|
|
265
|
+
{ token: 'invalid', background: 'cd3131' },
|
|
266
|
+
],
|
|
267
|
+
colors: {},
|
|
268
|
+
});
|
|
269
|
+
monaco.editor.defineTheme('kusto-dark2', {
|
|
270
|
+
base: 'vs-dark',
|
|
271
|
+
inherit: true,
|
|
272
|
+
rules: [],
|
|
273
|
+
colors: { 'editor.background': '#1B1A19' },
|
|
274
|
+
});
|
|
275
|
+
// Initialize kusto specific language features that don't currently have a natural way to extend using existing apis.
|
|
276
|
+
// Most other language features are initialized in kustoMode.ts
|
|
277
|
+
monaco.editor.onDidCreateEditor(function (editor) {
|
|
278
|
+
// hook up extension methods to editor.
|
|
279
|
+
extendedEditor_1.extend(editor);
|
|
280
|
+
commandHighlighter = new commandHighlighter_1.default(editor);
|
|
281
|
+
if (isStandaloneCodeEditor(editor)) {
|
|
282
|
+
commandFormatter = new commandFormatter_1.default(editor);
|
|
283
|
+
}
|
|
284
|
+
triggerSuggestDialogWhenCompletionItemSelected(editor);
|
|
285
|
+
});
|
|
286
|
+
function triggerSuggestDialogWhenCompletionItemSelected(editor) {
|
|
287
|
+
editor.onDidChangeCursorSelection(function (event) {
|
|
288
|
+
// checking the condition inside the event makes sure we will stay up to date whne kusto configuration changes at runtime.
|
|
289
|
+
if (kustoDefaults &&
|
|
290
|
+
kustoDefaults.languageSettings &&
|
|
291
|
+
kustoDefaults.languageSettings.openSuggestionDialogAfterPreviousSuggestionAccepted) {
|
|
292
|
+
var didAcceptSuggestion = event.source === 'modelChange' && event.reason === monaco.editor.CursorChangeReason.RecoverFromMarkers;
|
|
293
|
+
if (!didAcceptSuggestion) {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
event.selection;
|
|
297
|
+
var completionText = editor.getModel().getValueInRange(event.selection);
|
|
298
|
+
if (completionText[completionText.length - 1] === ' ') {
|
|
299
|
+
// OK so now we in a situation where we know a suggestion was selected and we want to trigger another one.
|
|
300
|
+
// the only problem is that the suggestion widget itself listens to this same event in order to know it needs to close.
|
|
301
|
+
// The only problem is that we're ahead in line, so we're triggering a suggest operation that will be shut down once
|
|
302
|
+
// the next callback is called. This is why we're waiting here - to let all the callbacks run synchronously and be
|
|
303
|
+
// the 'last' subscriber to run. Granted this is hacky, but until monaco provides a specific event for suggestions,
|
|
304
|
+
// this is the best we have.
|
|
305
|
+
setTimeout(function () { return editor.trigger('monaco-kusto', 'editor.action.triggerSuggest', {}); }, 10);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
function isStandaloneCodeEditor(editor) {
|
|
311
|
+
return editor.addAction !== undefined;
|
|
312
|
+
}
|
|
313
|
+
});
|
|
310
314
|
|