@kusto/monaco-kusto 4.0.4 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +88 -88
- package/release/dev/kustoMode.js +1127 -1127
- package/release/dev/kustoWorker.js +2047 -1859
- package/release/dev/monaco.contribution.js +323 -323
- package/release/esm/commandFormatter.js +34 -34
- package/release/esm/commandHighlighter.js +47 -47
- 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 +223 -199
- package/release/esm/languageFeatures.js +834 -834
- package/release/esm/languageService/kustoLanguageService.js +1752 -1588
- package/release/esm/languageService/kustoMonarchLanguageDefinition.js +76 -76
- package/release/esm/languageService/schema.js +64 -64
- package/release/esm/monaco.contribution.d.ts +13 -13
- package/release/esm/monaco.contribution.js +187 -187
- package/release/esm/monaco.d.ts +293 -240
- package/release/esm/workerManager.js +102 -102
- package/release/min/Kusto.Language.Bridge.min.js +1 -1
- package/release/min/kustoMode.js +1 -1
- package/release/min/kustoWorker.js +3 -3
- package/release/min/monaco.contribution.d.ts +13 -13
- package/release/min/monaco.contribution.js +1 -1
- package/release/min/monaco.d.ts +293 -240
- package/scripts/bundle.js +65 -65
- package/scripts/release.js +25 -25
package/release/dev/kustoMode.js
CHANGED
|
@@ -1,192 +1,192 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
define('vs/language/kusto/workerManager',["require", "exports"], function (require, exports) {
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.WorkerManager = void 0;
|
|
16
|
-
var WorkerManager = /** @class */ (function () {
|
|
17
|
-
function WorkerManager(_monacoInstance, defaults) {
|
|
18
|
-
var _this = this;
|
|
19
|
-
this._monacoInstance = _monacoInstance;
|
|
20
|
-
this._defaults = defaults;
|
|
21
|
-
this._worker = null;
|
|
22
|
-
this._idleCheckInterval = self.setInterval(function () { return _this._checkIfIdle(); }, 30 * 1000);
|
|
23
|
-
this._lastUsedTime = 0;
|
|
24
|
-
this._configChangeListener = this._defaults.onDidChange(function () { return _this._saveStateAndStopWorker(); });
|
|
25
|
-
}
|
|
26
|
-
WorkerManager.prototype._stopWorker = function () {
|
|
27
|
-
if (this._worker) {
|
|
28
|
-
this._worker.dispose();
|
|
29
|
-
this._worker = null;
|
|
30
|
-
}
|
|
31
|
-
this._client = null;
|
|
32
|
-
};
|
|
33
|
-
WorkerManager.prototype._saveStateAndStopWorker = function () {
|
|
34
|
-
var _this = this;
|
|
35
|
-
if (!this._worker) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
this._worker.getProxy().then(function (proxy) {
|
|
39
|
-
proxy.getSchema().then(function (schema) {
|
|
40
|
-
_this._storedState = { schema: schema };
|
|
41
|
-
_this._stopWorker();
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
WorkerManager.prototype.dispose = function () {
|
|
46
|
-
clearInterval(this._idleCheckInterval);
|
|
47
|
-
this._configChangeListener.dispose();
|
|
48
|
-
this._stopWorker();
|
|
49
|
-
};
|
|
50
|
-
WorkerManager.prototype._checkIfIdle = function () {
|
|
51
|
-
if (!this._worker) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
var maxIdleTime = this._defaults.getWorkerMaxIdleTime();
|
|
55
|
-
var timePassedSinceLastUsed = Date.now() - this._lastUsedTime;
|
|
56
|
-
if (maxIdleTime > 0 && timePassedSinceLastUsed > maxIdleTime) {
|
|
57
|
-
this._saveStateAndStopWorker();
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
WorkerManager.prototype._getClient = function () {
|
|
61
|
-
var _this = this;
|
|
62
|
-
this._lastUsedTime = Date.now();
|
|
63
|
-
// Since onDidProvideCompletionItems is not used in web worker, and since functions cannot be trivially serialized (throws exception unable to clone), We remove it here.
|
|
64
|
-
var _a = this._defaults.languageSettings, onDidProvideCompletionItems = _a.onDidProvideCompletionItems, languageSettings = __rest(_a, ["onDidProvideCompletionItems"]);
|
|
65
|
-
if (!this._client) {
|
|
66
|
-
this._worker = this._monacoInstance.editor.createWebWorker({
|
|
67
|
-
// module that exports the create() method and returns a `KustoWorker` instance
|
|
68
|
-
moduleId: 'vs/language/kusto/kustoWorker',
|
|
69
|
-
label: 'kusto',
|
|
70
|
-
// passed in to the create() method
|
|
71
|
-
createData: {
|
|
72
|
-
languageSettings: languageSettings,
|
|
73
|
-
languageId: 'kusto',
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
this._client = this._worker.getProxy().then(function (proxy) {
|
|
77
|
-
// push state we held onto before killing the client.
|
|
78
|
-
if (_this._storedState) {
|
|
79
|
-
return proxy.setSchema(_this._storedState.schema).then(function () { return proxy; });
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
return proxy;
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
return this._client;
|
|
87
|
-
};
|
|
88
|
-
WorkerManager.prototype.getLanguageServiceWorker = function () {
|
|
89
|
-
var _this = this;
|
|
90
|
-
var resources = [];
|
|
91
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
92
|
-
resources[_i] = arguments[_i];
|
|
93
|
-
}
|
|
94
|
-
var _client;
|
|
95
|
-
return this._getClient()
|
|
96
|
-
.then(function (client) {
|
|
97
|
-
_client = client;
|
|
98
|
-
})
|
|
99
|
-
.then(function (_) {
|
|
100
|
-
return _this._worker.withSyncedResources(resources);
|
|
101
|
-
})
|
|
102
|
-
.then(function (_) { return _client; });
|
|
103
|
-
};
|
|
104
|
-
return WorkerManager;
|
|
105
|
-
}());
|
|
106
|
-
exports.WorkerManager = WorkerManager;
|
|
107
|
-
});
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
define('vs/language/kusto/workerManager',["require", "exports"], function (require, exports) {
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.WorkerManager = void 0;
|
|
16
|
+
var WorkerManager = /** @class */ (function () {
|
|
17
|
+
function WorkerManager(_monacoInstance, defaults) {
|
|
18
|
+
var _this = this;
|
|
19
|
+
this._monacoInstance = _monacoInstance;
|
|
20
|
+
this._defaults = defaults;
|
|
21
|
+
this._worker = null;
|
|
22
|
+
this._idleCheckInterval = self.setInterval(function () { return _this._checkIfIdle(); }, 30 * 1000);
|
|
23
|
+
this._lastUsedTime = 0;
|
|
24
|
+
this._configChangeListener = this._defaults.onDidChange(function () { return _this._saveStateAndStopWorker(); });
|
|
25
|
+
}
|
|
26
|
+
WorkerManager.prototype._stopWorker = function () {
|
|
27
|
+
if (this._worker) {
|
|
28
|
+
this._worker.dispose();
|
|
29
|
+
this._worker = null;
|
|
30
|
+
}
|
|
31
|
+
this._client = null;
|
|
32
|
+
};
|
|
33
|
+
WorkerManager.prototype._saveStateAndStopWorker = function () {
|
|
34
|
+
var _this = this;
|
|
35
|
+
if (!this._worker) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
this._worker.getProxy().then(function (proxy) {
|
|
39
|
+
proxy.getSchema().then(function (schema) {
|
|
40
|
+
_this._storedState = { schema: schema };
|
|
41
|
+
_this._stopWorker();
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
WorkerManager.prototype.dispose = function () {
|
|
46
|
+
clearInterval(this._idleCheckInterval);
|
|
47
|
+
this._configChangeListener.dispose();
|
|
48
|
+
this._stopWorker();
|
|
49
|
+
};
|
|
50
|
+
WorkerManager.prototype._checkIfIdle = function () {
|
|
51
|
+
if (!this._worker) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
var maxIdleTime = this._defaults.getWorkerMaxIdleTime();
|
|
55
|
+
var timePassedSinceLastUsed = Date.now() - this._lastUsedTime;
|
|
56
|
+
if (maxIdleTime > 0 && timePassedSinceLastUsed > maxIdleTime) {
|
|
57
|
+
this._saveStateAndStopWorker();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
WorkerManager.prototype._getClient = function () {
|
|
61
|
+
var _this = this;
|
|
62
|
+
this._lastUsedTime = Date.now();
|
|
63
|
+
// Since onDidProvideCompletionItems is not used in web worker, and since functions cannot be trivially serialized (throws exception unable to clone), We remove it here.
|
|
64
|
+
var _a = this._defaults.languageSettings, onDidProvideCompletionItems = _a.onDidProvideCompletionItems, languageSettings = __rest(_a, ["onDidProvideCompletionItems"]);
|
|
65
|
+
if (!this._client) {
|
|
66
|
+
this._worker = this._monacoInstance.editor.createWebWorker({
|
|
67
|
+
// module that exports the create() method and returns a `KustoWorker` instance
|
|
68
|
+
moduleId: 'vs/language/kusto/kustoWorker',
|
|
69
|
+
label: 'kusto',
|
|
70
|
+
// passed in to the create() method
|
|
71
|
+
createData: {
|
|
72
|
+
languageSettings: languageSettings,
|
|
73
|
+
languageId: 'kusto',
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
this._client = this._worker.getProxy().then(function (proxy) {
|
|
77
|
+
// push state we held onto before killing the client.
|
|
78
|
+
if (_this._storedState) {
|
|
79
|
+
return proxy.setSchema(_this._storedState.schema).then(function () { return proxy; });
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
return proxy;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return this._client;
|
|
87
|
+
};
|
|
88
|
+
WorkerManager.prototype.getLanguageServiceWorker = function () {
|
|
89
|
+
var _this = this;
|
|
90
|
+
var resources = [];
|
|
91
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
92
|
+
resources[_i] = arguments[_i];
|
|
93
|
+
}
|
|
94
|
+
var _client;
|
|
95
|
+
return this._getClient()
|
|
96
|
+
.then(function (client) {
|
|
97
|
+
_client = client;
|
|
98
|
+
})
|
|
99
|
+
.then(function (_) {
|
|
100
|
+
return _this._worker.withSyncedResources(resources);
|
|
101
|
+
})
|
|
102
|
+
.then(function (_) { return _client; });
|
|
103
|
+
};
|
|
104
|
+
return WorkerManager;
|
|
105
|
+
}());
|
|
106
|
+
exports.WorkerManager = WorkerManager;
|
|
107
|
+
});
|
|
108
108
|
|
|
109
|
-
define('vs/language/kusto/languageService/kustoMonarchLanguageDefinition',["require", "exports"], function (require, exports) {
|
|
110
|
-
"use strict";
|
|
111
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
112
|
-
exports.KustoLanguageDefinition = void 0;
|
|
113
|
-
exports.KustoLanguageDefinition = {
|
|
114
|
-
name: 'kusto',
|
|
115
|
-
mimeTypes: ['text/kusto'],
|
|
116
|
-
displayName: "Kusto",
|
|
117
|
-
defaultToken: "invalid",
|
|
118
|
-
brackets: [['[', ']', 'delimiter.square'],
|
|
119
|
-
['(', ')', 'delimiter.parenthesis']],
|
|
120
|
-
wordDefinition: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
|
|
121
|
-
// .slice() call is for creating a shallow copy of the array since bridge.net shoves a $type property on the array which monaco doesn't like.
|
|
122
|
-
promotedOperatorCommandTokens: Kusto.Data.IntelliSense.CslCommandParser.PromotedOperatorCommandTokens.slice(0),
|
|
123
|
-
operatorCommandTokens: Kusto.Data.IntelliSense.CslCommandParser.OperatorCommandTokens.slice(0),
|
|
124
|
-
keywords: [
|
|
125
|
-
'by', 'on', 'contains', 'notcontains', 'containscs', 'notcontainscs', 'startswith', 'has', 'matches', 'regex', 'true',
|
|
126
|
-
'false', 'and', 'or', 'typeof', 'int', 'string', 'date', 'datetime', 'time', 'long', 'real', 'boolean', 'bool'
|
|
127
|
-
],
|
|
128
|
-
operators: ['+', '-', '*', '/', '>', '<', '==', '<>', '<=', '>=', '~', '!~'],
|
|
129
|
-
builtinFunctions: [
|
|
130
|
-
'countof', 'bin', 'extentid', 'extract', 'extractjson', 'floor', 'iif', 'isnull', 'isnotnull', 'notnull', 'isempty',
|
|
131
|
-
'isnotempty', 'notempty', 'now', 're2', 'strcat', 'strlen', 'toupper',
|
|
132
|
-
'tostring', 'count', 'cnt', 'sum', 'min', 'max', 'avg'
|
|
133
|
-
],
|
|
134
|
-
tokenizer: {
|
|
135
|
-
root: [
|
|
136
|
-
{ include: '@whitespace' },
|
|
137
|
-
{ include: '@numbers' },
|
|
138
|
-
{ include: '@strings' },
|
|
139
|
-
{ include: '@dqstrings' },
|
|
140
|
-
{ include: '@literals' },
|
|
141
|
-
{ include: '@comments' },
|
|
142
|
-
[/[;,.]/, 'delimiter'],
|
|
143
|
-
[/[()\[\]]/, '@brackets'],
|
|
144
|
-
[/[<>=!%&+\-*/|~^]/, 'operator'],
|
|
145
|
-
[/[\w@#\-$]+/, {
|
|
146
|
-
cases: {
|
|
147
|
-
'@keywords': 'keyword',
|
|
148
|
-
'@promotedOperatorCommandTokens': 'operator.sql',
|
|
149
|
-
'@operatorCommandTokens': 'keyword',
|
|
150
|
-
'@operators': 'operator',
|
|
151
|
-
'@builtinFunctions': 'predefined',
|
|
152
|
-
'@default': 'identifier',
|
|
153
|
-
}
|
|
154
|
-
}],
|
|
155
|
-
],
|
|
156
|
-
whitespace: [[/\s+/, 'white']],
|
|
157
|
-
comments: [["\\/\\/+.*", "comment"]],
|
|
158
|
-
numbers: [
|
|
159
|
-
[/0[xX][0-9a-fA-F]*/, 'number'],
|
|
160
|
-
[/[$][+-]*\d*(\.\d*)?/, 'number'],
|
|
161
|
-
[/((\d+(\.\d*)?)|(\.\d+))([eE][\-+]?\d+)?/, 'number']
|
|
162
|
-
],
|
|
163
|
-
strings: [
|
|
164
|
-
[/H'/, { token: 'string.quote', bracket: '@open', next: '@string' }],
|
|
165
|
-
[/h'/, { token: 'string.quote', bracket: '@open', next: '@string' }],
|
|
166
|
-
[/'/, { token: 'string.quote', bracket: '@open', next: '@string' }]
|
|
167
|
-
],
|
|
168
|
-
string: [
|
|
169
|
-
[/[^']+/, 'string'],
|
|
170
|
-
[/''/, 'string'],
|
|
171
|
-
[/'/, { token: 'string.quote', bracket: '@close', next: '@pop' }]
|
|
172
|
-
],
|
|
173
|
-
dqstrings: [
|
|
174
|
-
[/H"/, { token: 'string.quote', bracket: '@open', next: '@dqstring' }],
|
|
175
|
-
[/h"/, { token: 'string.quote', bracket: '@open', next: '@dqstring' }],
|
|
176
|
-
[/"/, { token: 'string.quote', bracket: '@open', next: '@dqstring' }]
|
|
177
|
-
],
|
|
178
|
-
dqstring: [
|
|
179
|
-
[/[^"]+/, 'string'],
|
|
180
|
-
[/""/, 'string'],
|
|
181
|
-
[/"/, { token: 'string.quote', bracket: '@close', next: '@pop' }]
|
|
182
|
-
],
|
|
183
|
-
literals: [[/datetime\(\d{4}-\d{2}-\d{2}(\s+\d{2}:\d{2}(:\d{2}(\.\d{0,3})?)?)?\)/, 'number'],
|
|
184
|
-
[/time\((\d+(s(ec(onds?)?)?|m(in(utes?)?)?|h(ours?)?|d(ays?)?)|(\s*(('[^']+')|("[^"]+"))\s*))\)/, 'number'],
|
|
185
|
-
[/guid\([\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}\)/, 'number'],
|
|
186
|
-
[/typeof\((int|string|date|datetime|time|long|real|boolean|bool)\)/, 'number']]
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
});
|
|
109
|
+
define('vs/language/kusto/languageService/kustoMonarchLanguageDefinition',["require", "exports"], function (require, exports) {
|
|
110
|
+
"use strict";
|
|
111
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
112
|
+
exports.KustoLanguageDefinition = void 0;
|
|
113
|
+
exports.KustoLanguageDefinition = {
|
|
114
|
+
name: 'kusto',
|
|
115
|
+
mimeTypes: ['text/kusto'],
|
|
116
|
+
displayName: "Kusto",
|
|
117
|
+
defaultToken: "invalid",
|
|
118
|
+
brackets: [['[', ']', 'delimiter.square'],
|
|
119
|
+
['(', ')', 'delimiter.parenthesis']],
|
|
120
|
+
wordDefinition: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
|
|
121
|
+
// .slice() call is for creating a shallow copy of the array since bridge.net shoves a $type property on the array which monaco doesn't like.
|
|
122
|
+
promotedOperatorCommandTokens: Kusto.Data.IntelliSense.CslCommandParser.PromotedOperatorCommandTokens.slice(0),
|
|
123
|
+
operatorCommandTokens: Kusto.Data.IntelliSense.CslCommandParser.OperatorCommandTokens.slice(0),
|
|
124
|
+
keywords: [
|
|
125
|
+
'by', 'on', 'contains', 'notcontains', 'containscs', 'notcontainscs', 'startswith', 'has', 'matches', 'regex', 'true',
|
|
126
|
+
'false', 'and', 'or', 'typeof', 'int', 'string', 'date', 'datetime', 'time', 'long', 'real', 'boolean', 'bool'
|
|
127
|
+
],
|
|
128
|
+
operators: ['+', '-', '*', '/', '>', '<', '==', '<>', '<=', '>=', '~', '!~'],
|
|
129
|
+
builtinFunctions: [
|
|
130
|
+
'countof', 'bin', 'extentid', 'extract', 'extractjson', 'floor', 'iif', 'isnull', 'isnotnull', 'notnull', 'isempty',
|
|
131
|
+
'isnotempty', 'notempty', 'now', 're2', 'strcat', 'strlen', 'toupper',
|
|
132
|
+
'tostring', 'count', 'cnt', 'sum', 'min', 'max', 'avg'
|
|
133
|
+
],
|
|
134
|
+
tokenizer: {
|
|
135
|
+
root: [
|
|
136
|
+
{ include: '@whitespace' },
|
|
137
|
+
{ include: '@numbers' },
|
|
138
|
+
{ include: '@strings' },
|
|
139
|
+
{ include: '@dqstrings' },
|
|
140
|
+
{ include: '@literals' },
|
|
141
|
+
{ include: '@comments' },
|
|
142
|
+
[/[;,.]/, 'delimiter'],
|
|
143
|
+
[/[()\[\]]/, '@brackets'],
|
|
144
|
+
[/[<>=!%&+\-*/|~^]/, 'operator'],
|
|
145
|
+
[/[\w@#\-$]+/, {
|
|
146
|
+
cases: {
|
|
147
|
+
'@keywords': 'keyword',
|
|
148
|
+
'@promotedOperatorCommandTokens': 'operator.sql',
|
|
149
|
+
'@operatorCommandTokens': 'keyword',
|
|
150
|
+
'@operators': 'operator',
|
|
151
|
+
'@builtinFunctions': 'predefined',
|
|
152
|
+
'@default': 'identifier',
|
|
153
|
+
}
|
|
154
|
+
}],
|
|
155
|
+
],
|
|
156
|
+
whitespace: [[/\s+/, 'white']],
|
|
157
|
+
comments: [["\\/\\/+.*", "comment"]],
|
|
158
|
+
numbers: [
|
|
159
|
+
[/0[xX][0-9a-fA-F]*/, 'number'],
|
|
160
|
+
[/[$][+-]*\d*(\.\d*)?/, 'number'],
|
|
161
|
+
[/((\d+(\.\d*)?)|(\.\d+))([eE][\-+]?\d+)?/, 'number']
|
|
162
|
+
],
|
|
163
|
+
strings: [
|
|
164
|
+
[/H'/, { token: 'string.quote', bracket: '@open', next: '@string' }],
|
|
165
|
+
[/h'/, { token: 'string.quote', bracket: '@open', next: '@string' }],
|
|
166
|
+
[/'/, { token: 'string.quote', bracket: '@open', next: '@string' }]
|
|
167
|
+
],
|
|
168
|
+
string: [
|
|
169
|
+
[/[^']+/, 'string'],
|
|
170
|
+
[/''/, 'string'],
|
|
171
|
+
[/'/, { token: 'string.quote', bracket: '@close', next: '@pop' }]
|
|
172
|
+
],
|
|
173
|
+
dqstrings: [
|
|
174
|
+
[/H"/, { token: 'string.quote', bracket: '@open', next: '@dqstring' }],
|
|
175
|
+
[/h"/, { token: 'string.quote', bracket: '@open', next: '@dqstring' }],
|
|
176
|
+
[/"/, { token: 'string.quote', bracket: '@open', next: '@dqstring' }]
|
|
177
|
+
],
|
|
178
|
+
dqstring: [
|
|
179
|
+
[/[^"]+/, 'string'],
|
|
180
|
+
[/""/, 'string'],
|
|
181
|
+
[/"/, { token: 'string.quote', bracket: '@close', next: '@pop' }]
|
|
182
|
+
],
|
|
183
|
+
literals: [[/datetime\(\d{4}-\d{2}-\d{2}(\s+\d{2}:\d{2}(:\d{2}(\.\d{0,3})?)?)?\)/, 'number'],
|
|
184
|
+
[/time\((\d+(s(ec(onds?)?)?|m(in(utes?)?)?|h(ours?)?|d(ays?)?)|(\s*(('[^']+')|("[^"]+"))\s*))\)/, 'number'],
|
|
185
|
+
[/guid\([\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}\)/, 'number'],
|
|
186
|
+
[/typeof\((int|string|date|datetime|time|long|real|boolean|bool)\)/, 'number']]
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
});
|
|
190
190
|
|
|
191
191
|
(function (factory) {
|
|
192
192
|
if (typeof module === "object" && typeof module.exports === "object") {
|
|
@@ -1871,944 +1871,944 @@ var t=_l[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:pop|shift)$/
|
|
|
1871
1871
|
Z.prototype.chain=tf,Z.prototype.commit=rf,Z.prototype.next=ef,Z.prototype.plant=of,Z.prototype.reverse=ff,Z.prototype.toJSON=Z.prototype.valueOf=Z.prototype.value=cf,Z.prototype.first=Z.prototype.head,Ul&&(Z.prototype[Ul]=uf),Z},be=de();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(re._=be,define('lodash/lodash.min',[],function(){return be})):ue?((ue.exports=be)._=be,ee._=be):re._=be}).call(this);
|
|
1872
1872
|
define('lodash', ['lodash/lodash.min'], function (main) { return main; });
|
|
1873
1873
|
|
|
1874
|
-
define('vs/language/kusto/languageFeatures',["require", "exports", "vscode-languageserver-types", "lodash"], function (require, exports, ls, _) {
|
|
1875
|
-
"use strict";
|
|
1876
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1877
|
-
exports.HoverAdapter = exports.FoldingAdapter = exports.FormatAdapter = exports.DocumentFormatAdapter = exports.RenameAdapter = exports.ReferenceAdapter = exports.DefinitionAdapter = exports.CompletionAdapter = exports.ColorizationAdapter = exports.DiagnosticsAdapter = void 0;
|
|
1878
|
-
var Uri = monaco.Uri;
|
|
1879
|
-
var Range = monaco.Range;
|
|
1880
|
-
var ClassificationKind = Kusto.Language.Editor.ClassificationKind;
|
|
1881
|
-
// --- diagnostics ---
|
|
1882
|
-
var DiagnosticsAdapter = /** @class */ (function () {
|
|
1883
|
-
function DiagnosticsAdapter(_monacoInstance, _languageId, _worker, defaults, onSchemaChange) {
|
|
1884
|
-
var _this = this;
|
|
1885
|
-
this._monacoInstance = _monacoInstance;
|
|
1886
|
-
this._languageId = _languageId;
|
|
1887
|
-
this._worker = _worker;
|
|
1888
|
-
this.defaults = defaults;
|
|
1889
|
-
this._disposables = [];
|
|
1890
|
-
this._contentListener = Object.create(null);
|
|
1891
|
-
this._configurationListener = Object.create(null);
|
|
1892
|
-
this._schemaListener = Object.create(null);
|
|
1893
|
-
var onModelAdd = function (model) {
|
|
1894
|
-
var modeId = model.getModeId();
|
|
1895
|
-
if (modeId !== _this._languageId) {
|
|
1896
|
-
return;
|
|
1897
|
-
}
|
|
1898
|
-
var debouncedValidation = _.debounce(function (intervals) { return _this._doValidate(model, modeId, intervals); }, 500);
|
|
1899
|
-
_this._contentListener[model.uri.toString()] = model.onDidChangeContent(function (e) {
|
|
1900
|
-
var intervalsToValidate = changeEventToIntervals(e);
|
|
1901
|
-
debouncedValidation(intervalsToValidate);
|
|
1902
|
-
});
|
|
1903
|
-
_this._configurationListener[model.uri.toString()] = _this.defaults.onDidChange(function () {
|
|
1904
|
-
self.setTimeout(function () { return _this._doValidate(model, modeId, []); }, 0);
|
|
1905
|
-
});
|
|
1906
|
-
_this._schemaListener[model.uri.toString()] = onSchemaChange(function () {
|
|
1907
|
-
self.setTimeout(function () { return _this._doValidate(model, modeId, []); }, 0);
|
|
1908
|
-
});
|
|
1909
|
-
};
|
|
1910
|
-
var onModelRemoved = function (model) {
|
|
1911
|
-
_this._monacoInstance.editor.setModelMarkers(model, _this._languageId, []);
|
|
1912
|
-
var uriStr = model.uri.toString();
|
|
1913
|
-
var contentListener = _this._contentListener[uriStr];
|
|
1914
|
-
if (contentListener) {
|
|
1915
|
-
contentListener.dispose();
|
|
1916
|
-
delete _this._contentListener[uriStr];
|
|
1917
|
-
}
|
|
1918
|
-
var configurationListener = _this._configurationListener[uriStr];
|
|
1919
|
-
if (configurationListener) {
|
|
1920
|
-
configurationListener.dispose();
|
|
1921
|
-
delete _this._configurationListener[uriStr];
|
|
1922
|
-
}
|
|
1923
|
-
var schemaListener = _this._schemaListener[uriStr];
|
|
1924
|
-
if (schemaListener) {
|
|
1925
|
-
schemaListener.dispose();
|
|
1926
|
-
delete _this._schemaListener[uriStr];
|
|
1927
|
-
}
|
|
1928
|
-
};
|
|
1929
|
-
this._disposables.push(this._monacoInstance.editor.onDidCreateModel(onModelAdd));
|
|
1930
|
-
this._disposables.push(this._monacoInstance.editor.onWillDisposeModel(onModelRemoved));
|
|
1931
|
-
this._disposables.push(this._monacoInstance.editor.onDidChangeModelLanguage(function (event) {
|
|
1932
|
-
onModelRemoved(event.model);
|
|
1933
|
-
onModelAdd(event.model);
|
|
1934
|
-
}));
|
|
1935
|
-
this._disposables.push({
|
|
1936
|
-
dispose: function () {
|
|
1937
|
-
for (var key in _this._contentListener) {
|
|
1938
|
-
_this._contentListener[key].dispose();
|
|
1939
|
-
}
|
|
1940
|
-
},
|
|
1941
|
-
});
|
|
1942
|
-
this._monacoInstance.editor.getModels().forEach(onModelAdd);
|
|
1943
|
-
}
|
|
1944
|
-
DiagnosticsAdapter.prototype.dispose = function () {
|
|
1945
|
-
this._disposables.forEach(function (d) { return d && d.dispose(); });
|
|
1946
|
-
this._disposables = [];
|
|
1947
|
-
};
|
|
1948
|
-
DiagnosticsAdapter.prototype._doValidate = function (model, languageId, intervals) {
|
|
1949
|
-
var _this = this;
|
|
1950
|
-
if (model.isDisposed()) {
|
|
1951
|
-
return;
|
|
1952
|
-
}
|
|
1953
|
-
var resource = model.uri;
|
|
1954
|
-
var versionNumberBefore = model.getVersionId();
|
|
1955
|
-
this._worker(resource)
|
|
1956
|
-
.then(function (worker) {
|
|
1957
|
-
return worker.doValidation(resource.toString(), intervals);
|
|
1958
|
-
})
|
|
1959
|
-
.then(function (diagnostics) {
|
|
1960
|
-
var newModel = _this._monacoInstance.editor.getModel(resource);
|
|
1961
|
-
var versionId = newModel.getVersionId();
|
|
1962
|
-
if (versionId !== versionNumberBefore) {
|
|
1963
|
-
return;
|
|
1964
|
-
}
|
|
1965
|
-
var markers = diagnostics.map(function (d) { return toDiagnostics(resource, d); });
|
|
1966
|
-
var model = _this._monacoInstance.editor.getModel(resource);
|
|
1967
|
-
var oldDecorations = model.getAllDecorations()
|
|
1968
|
-
.filter(function (decoration) { return decoration.options.className == "squiggly-error"; })
|
|
1969
|
-
.map(function (decoration) { return decoration.id; });
|
|
1970
|
-
if (model && model.getModeId() === languageId) {
|
|
1971
|
-
var syntaxErrorAsMarkDown = _this.defaults.languageSettings.syntaxErrorAsMarkDown;
|
|
1972
|
-
if (!syntaxErrorAsMarkDown || !syntaxErrorAsMarkDown.enableSyntaxErrorAsMarkDown) {
|
|
1973
|
-
// Remove previous syntax error decorations and set the new markers (for example, when disabling syntaxErrorAsMarkDown after it was enabled)
|
|
1974
|
-
model.deltaDecorations(oldDecorations, []);
|
|
1975
|
-
_this._monacoInstance.editor.setModelMarkers(model, languageId, markers);
|
|
1976
|
-
}
|
|
1977
|
-
else {
|
|
1978
|
-
// Add custom popup for syntax error: icon, header and message as markdown
|
|
1979
|
-
var header = syntaxErrorAsMarkDown.header ? "**" + syntaxErrorAsMarkDown.header + "** \n\n" : "";
|
|
1980
|
-
var icon = syntaxErrorAsMarkDown.icon ? "" : "";
|
|
1981
|
-
var popupErrorHoverHeaderMessage_1 = icon + " " + header;
|
|
1982
|
-
var newDecorations = markers.map(function (marker) {
|
|
1983
|
-
return {
|
|
1984
|
-
range: {
|
|
1985
|
-
startLineNumber: marker.startLineNumber,
|
|
1986
|
-
startColumn: marker.startColumn,
|
|
1987
|
-
endLineNumber: marker.endLineNumber,
|
|
1988
|
-
endColumn: marker.endColumn
|
|
1989
|
-
},
|
|
1990
|
-
options: {
|
|
1991
|
-
hoverMessage: {
|
|
1992
|
-
value: popupErrorHoverHeaderMessage_1 + marker.message
|
|
1993
|
-
},
|
|
1994
|
-
className: "squiggly-error",
|
|
1995
|
-
zIndex: 100,
|
|
1996
|
-
overviewRuler: {
|
|
1997
|
-
// The color indication on the right ruler
|
|
1998
|
-
color: "rgb(255, 18, 18, 0.7)",
|
|
1999
|
-
position: monaco.editor.OverviewRulerLane.Right
|
|
2000
|
-
},
|
|
2001
|
-
minimap: {
|
|
2002
|
-
color: "rgb(255, 18, 18, 0.7)",
|
|
2003
|
-
position: monaco.editor.MinimapPosition.Inline
|
|
2004
|
-
}
|
|
2005
|
-
}
|
|
2006
|
-
};
|
|
2007
|
-
});
|
|
2008
|
-
var oldMarkers = monaco.editor.getModelMarkers({
|
|
2009
|
-
owner: languageId,
|
|
2010
|
-
resource: resource
|
|
2011
|
-
}).filter(function (marker) { return marker.severity == monaco.MarkerSeverity.Error; });
|
|
2012
|
-
if (oldMarkers && oldMarkers.length > 0) {
|
|
2013
|
-
// In case there were previous markers, remove their decorations (for example, when enabling syntaxErrorAsMarkDown after it was disabled)
|
|
2014
|
-
oldDecorations = [];
|
|
2015
|
-
// Remove previous markers
|
|
2016
|
-
_this._monacoInstance.editor.setModelMarkers(model, languageId, []);
|
|
2017
|
-
}
|
|
2018
|
-
// Remove previous syntax error decorations and set the new decorations
|
|
2019
|
-
model.deltaDecorations(oldDecorations, newDecorations);
|
|
2020
|
-
}
|
|
2021
|
-
}
|
|
2022
|
-
})
|
|
2023
|
-
.then(undefined, function (err) {
|
|
2024
|
-
console.error(err);
|
|
2025
|
-
});
|
|
2026
|
-
};
|
|
2027
|
-
return DiagnosticsAdapter;
|
|
2028
|
-
}());
|
|
2029
|
-
exports.DiagnosticsAdapter = DiagnosticsAdapter;
|
|
2030
|
-
function changeEventToIntervals(e) {
|
|
2031
|
-
return e.changes.map(function (change) { return ({
|
|
2032
|
-
start: change.rangeOffset,
|
|
2033
|
-
end: change.rangeOffset + change.text.length,
|
|
2034
|
-
}); });
|
|
2035
|
-
}
|
|
2036
|
-
function toSeverity(lsSeverity) {
|
|
2037
|
-
switch (lsSeverity) {
|
|
2038
|
-
case ls.DiagnosticSeverity.Error:
|
|
2039
|
-
return monaco.MarkerSeverity.Error;
|
|
2040
|
-
case ls.DiagnosticSeverity.Warning:
|
|
2041
|
-
return monaco.MarkerSeverity.Warning;
|
|
2042
|
-
case ls.DiagnosticSeverity.Information:
|
|
2043
|
-
return monaco.MarkerSeverity.Info;
|
|
2044
|
-
case ls.DiagnosticSeverity.Hint:
|
|
2045
|
-
return monaco.MarkerSeverity.Hint;
|
|
2046
|
-
default:
|
|
2047
|
-
return monaco.MarkerSeverity.Info;
|
|
2048
|
-
}
|
|
2049
|
-
}
|
|
2050
|
-
function toDiagnostics(resource, diag) {
|
|
2051
|
-
var code = typeof diag.code === 'number' ? String(diag.code) : diag.code;
|
|
2052
|
-
return {
|
|
2053
|
-
severity: toSeverity(diag.severity),
|
|
2054
|
-
startLineNumber: diag.range.start.line + 1,
|
|
2055
|
-
startColumn: diag.range.start.character + 1,
|
|
2056
|
-
endLineNumber: diag.range.end.line + 1,
|
|
2057
|
-
endColumn: diag.range.end.character + 1,
|
|
2058
|
-
message: diag.message,
|
|
2059
|
-
code: code,
|
|
2060
|
-
source: diag.source,
|
|
2061
|
-
};
|
|
2062
|
-
}
|
|
2063
|
-
// --- colorization ---
|
|
2064
|
-
function fromIRange(range) {
|
|
2065
|
-
if (!range) {
|
|
2066
|
-
return undefined;
|
|
2067
|
-
}
|
|
2068
|
-
if (range instanceof monaco.Range) {
|
|
2069
|
-
return { start: fromPosition(range.getStartPosition()), end: fromPosition(range.getEndPosition()) };
|
|
2070
|
-
}
|
|
2071
|
-
var startLineNumber = range.startLineNumber, startColumn = range.startColumn, endLineNumber = range.endLineNumber, endColumn = range.endColumn;
|
|
2072
|
-
range = new monaco.Range(startLineNumber, startColumn, endLineNumber, endColumn);
|
|
2073
|
-
}
|
|
2074
|
-
// commented here is the color definitions are were defined by v1 intellisense terminology:
|
|
2075
|
-
// { token: 'comment', foreground: '008000' }, // CommentToken Green
|
|
2076
|
-
// { token: 'variable.predefined', foreground: '800080' }, // CalculatedColumnToken Purple
|
|
2077
|
-
// { token: 'function', foreground: '0000FF' }, // FunctionNameToken Blue
|
|
2078
|
-
// { token: 'operator.sql', foreground: 'FF4500' }, // OperatorToken OrangeRed (now changed to darker color CC3700 because wasn't accessible)
|
|
2079
|
-
// { token: 'string', foreground: 'B22222' }, // StringLiteralToken Firebrick
|
|
2080
|
-
// { token: 'operator.scss', foreground: '0000FF' }, // SubOperatorToken Blue
|
|
2081
|
-
// { token: 'variable', foreground: 'C71585' }, // TableColumnToken MediumVioletRed
|
|
2082
|
-
// { token: 'variable.parameter', foreground: '9932CC' }, // TableToken DarkOrchid
|
|
2083
|
-
// { token: '', foreground: '000000' }, // UnknownToken, PlainTextToken Black
|
|
2084
|
-
// { token: 'type', foreground: '0000FF' }, // DataTypeToken Blue
|
|
2085
|
-
// { token: 'tag', foreground: '0000FF' }, // ControlCommandToken Blue
|
|
2086
|
-
// { token: 'annotation', foreground: '2B91AF' }, // QueryParametersToken FF2B91AF
|
|
2087
|
-
// { token: 'keyword', foreground: '0000FF' }, // CslCommandToken, PluginToken Blue
|
|
2088
|
-
// { token: 'number', foreground: '191970' }, // LetVariablesToken MidnightBlue
|
|
2089
|
-
// { token: 'annotation', foreground: '9400D3' }, // ClientDirectiveToken DarkViolet
|
|
2090
|
-
// { token: 'invalid', background: 'cd3131' },
|
|
2091
|
-
var classificationToColorLight = {
|
|
2092
|
-
Column: 'C71585',
|
|
2093
|
-
Comment: '008000',
|
|
2094
|
-
Database: 'C71585',
|
|
2095
|
-
Function: '0000FF',
|
|
2096
|
-
Identifier: '000000',
|
|
2097
|
-
Keyword: '0000FF',
|
|
2098
|
-
Literal: 'B22222',
|
|
2099
|
-
ScalarOperator: '000000',
|
|
2100
|
-
MaterializedView: 'C71585',
|
|
2101
|
-
MathOperator: '000000',
|
|
2102
|
-
Command: '0000FF',
|
|
2103
|
-
Parameter: '2B91AF',
|
|
2104
|
-
PlainText: '000000',
|
|
2105
|
-
Punctuation: '000000',
|
|
2106
|
-
QueryOperator: 'CC3700',
|
|
2107
|
-
QueryParameter: 'CC3700',
|
|
2108
|
-
StringLiteral: 'B22222',
|
|
2109
|
-
Table: 'C71585',
|
|
2110
|
-
Type: '0000FF',
|
|
2111
|
-
Variable: '191970',
|
|
2112
|
-
Directive: '9400D3',
|
|
2113
|
-
ClientParameter: 'b5cea8',
|
|
2114
|
-
SchemaMember: 'C71585',
|
|
2115
|
-
SignatureParameter: '2B91AF',
|
|
2116
|
-
Option: '000000',
|
|
2117
|
-
};
|
|
2118
|
-
var classificationToColorDark = {
|
|
2119
|
-
Column: '4ec9b0',
|
|
2120
|
-
Comment: '608B4E',
|
|
2121
|
-
Database: 'c586c0',
|
|
2122
|
-
Function: 'dcdcaa',
|
|
2123
|
-
Identifier: 'd4d4d4',
|
|
2124
|
-
Keyword: '569cd6',
|
|
2125
|
-
Literal: 'ce9178',
|
|
2126
|
-
ScalarOperator: 'd4d4d4',
|
|
2127
|
-
MaterializedView: 'c586c0',
|
|
2128
|
-
MathOperator: 'd4d4d4',
|
|
2129
|
-
Command: 'd4d4d4',
|
|
2130
|
-
Parameter: '2B91AF',
|
|
2131
|
-
PlainText: 'd4d4d4',
|
|
2132
|
-
Punctuation: 'd4d4d4',
|
|
2133
|
-
QueryOperator: '9cdcfe',
|
|
2134
|
-
QueryParameter: '9cdcfe',
|
|
2135
|
-
StringLiteral: 'ce9178',
|
|
2136
|
-
Table: 'c586c0',
|
|
2137
|
-
Type: '569cd6',
|
|
2138
|
-
Variable: 'd7ba7d',
|
|
2139
|
-
Directive: 'b5cea8',
|
|
2140
|
-
ClientParameter: 'b5cea8',
|
|
2141
|
-
SchemaMember: '4ec9b0',
|
|
2142
|
-
SignatureParameter: '2B91AF',
|
|
2143
|
-
Option: 'd4d4d4',
|
|
2144
|
-
};
|
|
2145
|
-
var ColorizationAdapter = /** @class */ (function () {
|
|
2146
|
-
function ColorizationAdapter(_monacoInstance, _languageId, _worker, defaults, onSchemaChange) {
|
|
2147
|
-
var _this = this;
|
|
2148
|
-
this._monacoInstance = _monacoInstance;
|
|
2149
|
-
this._languageId = _languageId;
|
|
2150
|
-
this._worker = _worker;
|
|
2151
|
-
this._disposables = [];
|
|
2152
|
-
this._contentListener = Object.create(null);
|
|
2153
|
-
this._configurationListener = Object.create(null);
|
|
2154
|
-
this._schemaListener = Object.create(null);
|
|
2155
|
-
this.decorations = [];
|
|
2156
|
-
injectCss();
|
|
2157
|
-
var onModelAdd = function (model) {
|
|
2158
|
-
var modeId = model.getModeId();
|
|
2159
|
-
if (modeId !== _this._languageId) {
|
|
2160
|
-
return;
|
|
2161
|
-
}
|
|
2162
|
-
var debouncedColorization = _.debounce(function (intervals) { return _this._doColorization(model, modeId, intervals); }, 500);
|
|
2163
|
-
var handle;
|
|
2164
|
-
_this._contentListener[model.uri.toString()] = model.onDidChangeContent(function (e) {
|
|
2165
|
-
// Changes are represented as a range in doc before change, plus the text that it was replaced with.
|
|
2166
|
-
// We are interested in the range _after_ the change (since that's what we need to colorize).
|
|
2167
|
-
// folowing logic calculates that.
|
|
2168
|
-
var intervalsToColorize = changeEventToIntervals(e);
|
|
2169
|
-
debouncedColorization(intervalsToColorize);
|
|
2170
|
-
});
|
|
2171
|
-
_this._configurationListener[model.uri.toString()] = defaults.onDidChange(function () {
|
|
2172
|
-
self.setTimeout(function () { return _this._doColorization(model, modeId, []); }, 0);
|
|
2173
|
-
});
|
|
2174
|
-
_this._schemaListener[model.uri.toString()] = onSchemaChange(function () {
|
|
2175
|
-
self.setTimeout(function () { return _this._doColorization(model, modeId, []); }, 0);
|
|
2176
|
-
});
|
|
2177
|
-
};
|
|
2178
|
-
var onModelRemoved = function (model) {
|
|
2179
|
-
model.deltaDecorations(_this.decorations, []);
|
|
2180
|
-
var uriStr = model.uri.toString();
|
|
2181
|
-
var contentListener = _this._contentListener[uriStr];
|
|
2182
|
-
if (contentListener) {
|
|
2183
|
-
contentListener.dispose();
|
|
2184
|
-
delete _this._contentListener[uriStr];
|
|
2185
|
-
}
|
|
2186
|
-
var configurationListener = _this._configurationListener[uriStr];
|
|
2187
|
-
if (configurationListener) {
|
|
2188
|
-
configurationListener.dispose();
|
|
2189
|
-
delete _this._configurationListener[uriStr];
|
|
2190
|
-
}
|
|
2191
|
-
var schemaListener = _this._configurationListener[uriStr];
|
|
2192
|
-
if (schemaListener) {
|
|
2193
|
-
schemaListener.dispose();
|
|
2194
|
-
delete _this._schemaListener[uriStr];
|
|
2195
|
-
}
|
|
2196
|
-
};
|
|
2197
|
-
this._disposables.push(this._monacoInstance.editor.onDidCreateModel(onModelAdd));
|
|
2198
|
-
this._disposables.push(this._monacoInstance.editor.onWillDisposeModel(onModelRemoved));
|
|
2199
|
-
this._disposables.push(this._monacoInstance.editor.onDidChangeModelLanguage(function (event) {
|
|
2200
|
-
onModelRemoved(event.model);
|
|
2201
|
-
onModelAdd(event.model);
|
|
2202
|
-
}));
|
|
2203
|
-
this._disposables.push({
|
|
2204
|
-
dispose: function () {
|
|
2205
|
-
for (var key in _this._contentListener) {
|
|
2206
|
-
_this._contentListener[key].dispose();
|
|
2207
|
-
}
|
|
2208
|
-
},
|
|
2209
|
-
});
|
|
2210
|
-
this._monacoInstance.editor.getModels().forEach(onModelAdd);
|
|
2211
|
-
}
|
|
2212
|
-
ColorizationAdapter.prototype.dispose = function () {
|
|
2213
|
-
this._disposables.forEach(function (d) { return d && d.dispose(); });
|
|
2214
|
-
this._disposables = [];
|
|
2215
|
-
};
|
|
2216
|
-
/**
|
|
2217
|
-
* Return true if the range doesn't intersect any of the line ranges.
|
|
2218
|
-
* @param range Range
|
|
2219
|
-
* @param impactedLineRanges an array of line ranges
|
|
2220
|
-
*/
|
|
2221
|
-
ColorizationAdapter.prototype._rangeDoesNotIntersectAny = function (range, impactedLineRanges) {
|
|
2222
|
-
return impactedLineRanges.every(function (lineRange) {
|
|
2223
|
-
return range.startLineNumber > lineRange.lastImpactedLine || range.endLineNumber < lineRange.firstImpactedLine;
|
|
2224
|
-
});
|
|
2225
|
-
};
|
|
2226
|
-
ColorizationAdapter.prototype._doColorization = function (model, languageId, intervals) {
|
|
2227
|
-
var _this = this;
|
|
2228
|
-
if (model.isDisposed()) {
|
|
2229
|
-
return;
|
|
2230
|
-
}
|
|
2231
|
-
var resource = model.uri;
|
|
2232
|
-
var versionNumberBeforeColorization = model.getVersionId();
|
|
2233
|
-
this._worker(resource)
|
|
2234
|
-
.then(function (worker) {
|
|
2235
|
-
return worker.doColorization(resource.toString(), intervals);
|
|
2236
|
-
})
|
|
2237
|
-
.then(function (colorizationRanges) {
|
|
2238
|
-
var newModel = _this._monacoInstance.editor.getModel(model.uri);
|
|
2239
|
-
var versionId = newModel.getVersionId();
|
|
2240
|
-
// don't colorize an older version of the document.
|
|
2241
|
-
if (versionId !== versionNumberBeforeColorization) {
|
|
2242
|
-
return;
|
|
2243
|
-
}
|
|
2244
|
-
var decorationRanges = colorizationRanges.map(function (colorizationRange) {
|
|
2245
|
-
var decorations = colorizationRange.classifications
|
|
2246
|
-
.map(function (classification) { return toDecoration(model, classification); })
|
|
2247
|
-
// The following line will prevent things that aren't going to be colorized anyway to get a CSS class.
|
|
2248
|
-
// This will prevent the case where the non-semantic colorizer already figured out that a keyword needs
|
|
2249
|
-
// to be colorized, but the outdated semantic colorizer still thinks it's a plain text and wants it colored
|
|
2250
|
-
// in black.
|
|
2251
|
-
.filter(function (d) {
|
|
2252
|
-
return d.options.inlineClassName !== 'PlainText' && d.options.inlineClassName != 'Identifier';
|
|
2253
|
-
});
|
|
2254
|
-
var firstImpactedLine = model.getPositionAt(colorizationRange.absoluteStart).lineNumber;
|
|
2255
|
-
var endPosition = model.getPositionAt(colorizationRange.absoluteEnd);
|
|
2256
|
-
// A token that ends in the first column of the next line is not considered to be part of that line.
|
|
2257
|
-
var lastImpactedLine = endPosition.column == 1 && endPosition.lineNumber > 1
|
|
2258
|
-
? endPosition.lineNumber - 1
|
|
2259
|
-
: endPosition.lineNumber;
|
|
2260
|
-
return { decorations: decorations, firstImpactedLine: firstImpactedLine, lastImpactedLine: lastImpactedLine };
|
|
2261
|
-
});
|
|
2262
|
-
// Compute the previous decorations we want to replace with the new ones.
|
|
2263
|
-
var oldDecorations = decorationRanges
|
|
2264
|
-
.map(function (range) {
|
|
2265
|
-
return model
|
|
2266
|
-
.getLinesDecorations(range.firstImpactedLine, range.lastImpactedLine)
|
|
2267
|
-
.filter(function (d) { return classificationToColorLight[d.options.inlineClassName]; }) // Don't delete any other decorations
|
|
2268
|
-
.map(function (d) { return d.id; });
|
|
2269
|
-
})
|
|
2270
|
-
.reduce(function (prev, curr) { return prev.concat(curr); }, []);
|
|
2271
|
-
// Flatten decoration groups to an array of decorations
|
|
2272
|
-
var newDecorations = decorationRanges.reduce(function (prev, next) { return prev.concat(next.decorations); }, []);
|
|
2273
|
-
if (model && model.getModeId() === languageId) {
|
|
2274
|
-
_this.decorations = model.deltaDecorations(oldDecorations, newDecorations);
|
|
2275
|
-
}
|
|
2276
|
-
})
|
|
2277
|
-
.then(undefined, function (err) {
|
|
2278
|
-
console.error(err);
|
|
2279
|
-
});
|
|
2280
|
-
};
|
|
2281
|
-
return ColorizationAdapter;
|
|
2282
|
-
}());
|
|
2283
|
-
exports.ColorizationAdapter = ColorizationAdapter;
|
|
2284
|
-
/**
|
|
2285
|
-
* Gets all keys of an enum (the string keys not the numeric values).
|
|
2286
|
-
* @param e Enum type
|
|
2287
|
-
*/
|
|
2288
|
-
function getEnumKeys(e) {
|
|
2289
|
-
return Object.keys(e).filter(function (k) { return typeof e[k] === 'number'; });
|
|
2290
|
-
}
|
|
2291
|
-
/**
|
|
2292
|
-
* Generates a mapping between ClassificationKind and color.
|
|
2293
|
-
*/
|
|
2294
|
-
function getClassificationColorTriplets() {
|
|
2295
|
-
var keys = getEnumKeys(ClassificationKind);
|
|
2296
|
-
var result = keys.map(function (key) { return ({
|
|
2297
|
-
classification: key,
|
|
2298
|
-
colorLight: classificationToColorLight[key],
|
|
2299
|
-
colorDark: classificationToColorDark[key],
|
|
2300
|
-
}); });
|
|
2301
|
-
return result;
|
|
2302
|
-
}
|
|
2303
|
-
/**
|
|
2304
|
-
* Returns a string which is a css describing all tokens and their colors.
|
|
2305
|
-
* looks a little bit something like this:
|
|
2306
|
-
*
|
|
2307
|
-
* .vs .Literal {color: '#000000';} .vs-dark .Literal {color: '#FFFFFF';}
|
|
2308
|
-
* .vs .Comment {color: '#111111';} .vs-dark .Comment {color: '#EEEEEE';}
|
|
2309
|
-
*/
|
|
2310
|
-
function getCssForClassification() {
|
|
2311
|
-
var classificationColorTriplets = getClassificationColorTriplets();
|
|
2312
|
-
var cssInnerHtml = classificationColorTriplets
|
|
2313
|
-
.map(function (pair) {
|
|
2314
|
-
return ".vs ." + pair.classification + " {color: #" + pair.colorLight + ";} .vs-dark ." + pair.classification + " {color: #" + pair.colorDark + ";}";
|
|
2315
|
-
})
|
|
2316
|
-
.join('\n');
|
|
2317
|
-
return cssInnerHtml;
|
|
2318
|
-
}
|
|
2319
|
-
/**
|
|
2320
|
-
* Inject a CSS sheet to the head of document, coloring kusto elements by classification.
|
|
2321
|
-
* TODO: make idempotent
|
|
2322
|
-
*/
|
|
2323
|
-
function injectCss() {
|
|
2324
|
-
var container = document.getElementsByTagName('head')[0];
|
|
2325
|
-
var style = document.createElement('style');
|
|
2326
|
-
style.type = 'text/css';
|
|
2327
|
-
style.media = 'screen';
|
|
2328
|
-
container.appendChild(style);
|
|
2329
|
-
ClassificationKind;
|
|
2330
|
-
style.innerHTML = getCssForClassification();
|
|
2331
|
-
}
|
|
2332
|
-
function toDecoration(model, classification) {
|
|
2333
|
-
var start = model.getPositionAt(classification.start);
|
|
2334
|
-
var end = model.getPositionAt(classification.start + classification.length);
|
|
2335
|
-
var range = new Range(start.lineNumber, start.column, end.lineNumber, end.column);
|
|
2336
|
-
var inlineClassName = ClassificationKind.$names[classification.kind];
|
|
2337
|
-
return {
|
|
2338
|
-
range: range,
|
|
2339
|
-
options: {
|
|
2340
|
-
inlineClassName: inlineClassName,
|
|
2341
|
-
stickiness: monaco.editor.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
|
|
2342
|
-
},
|
|
2343
|
-
};
|
|
2344
|
-
}
|
|
2345
|
-
// --- completion ------
|
|
2346
|
-
function fromPosition(position) {
|
|
2347
|
-
if (!position) {
|
|
2348
|
-
return void 0;
|
|
2349
|
-
}
|
|
2350
|
-
return { character: position.column - 1, line: position.lineNumber - 1 };
|
|
2351
|
-
}
|
|
2352
|
-
function fromRange(range) {
|
|
2353
|
-
if (!range) {
|
|
2354
|
-
return void 0;
|
|
2355
|
-
}
|
|
2356
|
-
return { start: fromPosition(range.getStartPosition()), end: fromPosition(range.getEndPosition()) };
|
|
2357
|
-
}
|
|
2358
|
-
function toRange(range) {
|
|
2359
|
-
if (!range) {
|
|
2360
|
-
return void 0;
|
|
2361
|
-
}
|
|
2362
|
-
return new Range(range.start.line + 1, range.start.character + 1, range.end.line + 1, range.end.character + 1);
|
|
2363
|
-
}
|
|
2364
|
-
function toCompletionItemKind(kind) {
|
|
2365
|
-
var mItemKind = monaco.languages.CompletionItemKind;
|
|
2366
|
-
switch (kind) {
|
|
2367
|
-
case ls.CompletionItemKind.Text:
|
|
2368
|
-
return mItemKind.Text;
|
|
2369
|
-
case ls.CompletionItemKind.Method:
|
|
2370
|
-
return mItemKind.Method;
|
|
2371
|
-
case ls.CompletionItemKind.Function:
|
|
2372
|
-
return mItemKind.Function;
|
|
2373
|
-
case ls.CompletionItemKind.Constructor:
|
|
2374
|
-
return mItemKind.Constructor;
|
|
2375
|
-
case ls.CompletionItemKind.Field:
|
|
2376
|
-
return mItemKind.Field;
|
|
2377
|
-
case ls.CompletionItemKind.Variable:
|
|
2378
|
-
return mItemKind.Variable;
|
|
2379
|
-
case ls.CompletionItemKind.Class:
|
|
2380
|
-
return mItemKind.Class;
|
|
2381
|
-
case ls.CompletionItemKind.Interface:
|
|
2382
|
-
return mItemKind.Interface;
|
|
2383
|
-
case ls.CompletionItemKind.Module:
|
|
2384
|
-
return mItemKind.Module;
|
|
2385
|
-
case ls.CompletionItemKind.Property:
|
|
2386
|
-
return mItemKind.Property;
|
|
2387
|
-
case ls.CompletionItemKind.Unit:
|
|
2388
|
-
return mItemKind.Unit;
|
|
2389
|
-
case ls.CompletionItemKind.Value:
|
|
2390
|
-
return mItemKind.Value;
|
|
2391
|
-
case ls.CompletionItemKind.Enum:
|
|
2392
|
-
return mItemKind.Enum;
|
|
2393
|
-
case ls.CompletionItemKind.Keyword:
|
|
2394
|
-
return mItemKind.Keyword;
|
|
2395
|
-
case ls.CompletionItemKind.Snippet:
|
|
2396
|
-
return mItemKind.Snippet;
|
|
2397
|
-
case ls.CompletionItemKind.Color:
|
|
2398
|
-
return mItemKind.Color;
|
|
2399
|
-
case ls.CompletionItemKind.File:
|
|
2400
|
-
return mItemKind.File;
|
|
2401
|
-
case ls.CompletionItemKind.Reference:
|
|
2402
|
-
return mItemKind.Reference;
|
|
2403
|
-
}
|
|
2404
|
-
return mItemKind.Property;
|
|
2405
|
-
}
|
|
2406
|
-
function toTextEdit(textEdit) {
|
|
2407
|
-
if (!textEdit) {
|
|
2408
|
-
return void 0;
|
|
2409
|
-
}
|
|
2410
|
-
return {
|
|
2411
|
-
range: toRange(textEdit.range),
|
|
2412
|
-
text: textEdit.newText,
|
|
2413
|
-
};
|
|
2414
|
-
}
|
|
2415
|
-
var CompletionAdapter = /** @class */ (function () {
|
|
2416
|
-
function CompletionAdapter(_worker, languageSettings) {
|
|
2417
|
-
this._worker = _worker;
|
|
2418
|
-
this.languageSettings = languageSettings;
|
|
2419
|
-
}
|
|
2420
|
-
Object.defineProperty(CompletionAdapter.prototype, "triggerCharacters", {
|
|
2421
|
-
get: function () {
|
|
2422
|
-
return [' '];
|
|
2423
|
-
},
|
|
2424
|
-
enumerable: false,
|
|
2425
|
-
configurable: true
|
|
2426
|
-
});
|
|
2427
|
-
CompletionAdapter.prototype.provideCompletionItems = function (model, position, context, token) {
|
|
2428
|
-
var wordInfo = model.getWordUntilPosition(position);
|
|
2429
|
-
var wordRange = new Range(position.lineNumber, wordInfo.startColumn, position.lineNumber, wordInfo.endColumn);
|
|
2430
|
-
var resource = model.uri;
|
|
2431
|
-
var onDidProvideCompletionItems = this.languageSettings
|
|
2432
|
-
.onDidProvideCompletionItems;
|
|
2433
|
-
return this._worker(resource)
|
|
2434
|
-
.then(function (worker) {
|
|
2435
|
-
return worker.doComplete(resource.toString(), fromPosition(position));
|
|
2436
|
-
})
|
|
2437
|
-
.then(function (info) { return (onDidProvideCompletionItems ? onDidProvideCompletionItems(info) : info); })
|
|
2438
|
-
.then(function (info) {
|
|
2439
|
-
if (!info) {
|
|
2440
|
-
return;
|
|
2441
|
-
}
|
|
2442
|
-
var items = info.items.map(function (entry) {
|
|
2443
|
-
var item = {
|
|
2444
|
-
label: entry.label,
|
|
2445
|
-
insertText: entry.insertText,
|
|
2446
|
-
sortText: entry.sortText,
|
|
2447
|
-
filterText: entry.filterText,
|
|
2448
|
-
documentation: entry.documentation,
|
|
2449
|
-
detail: entry.detail,
|
|
2450
|
-
range: wordRange,
|
|
2451
|
-
kind: toCompletionItemKind(entry.kind),
|
|
2452
|
-
};
|
|
2453
|
-
if (entry.textEdit) {
|
|
2454
|
-
item.range = toRange(entry.textEdit.range);
|
|
2455
|
-
item.insertText = entry.textEdit.newText;
|
|
2456
|
-
}
|
|
2457
|
-
if (entry.insertTextFormat === ls.InsertTextFormat.Snippet) {
|
|
2458
|
-
item.insertTextRules = monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet;
|
|
2459
|
-
}
|
|
2460
|
-
return item;
|
|
2461
|
-
});
|
|
2462
|
-
return {
|
|
2463
|
-
isIncomplete: info.isIncomplete,
|
|
2464
|
-
suggestions: items,
|
|
2465
|
-
};
|
|
2466
|
-
});
|
|
2467
|
-
};
|
|
2468
|
-
return CompletionAdapter;
|
|
2469
|
-
}());
|
|
2470
|
-
exports.CompletionAdapter = CompletionAdapter;
|
|
2471
|
-
function isMarkupContent(thing) {
|
|
2472
|
-
return thing && typeof thing === 'object' && typeof thing.kind === 'string';
|
|
2473
|
-
}
|
|
2474
|
-
function toMarkdownString(entry) {
|
|
2475
|
-
if (typeof entry === 'string') {
|
|
2476
|
-
return {
|
|
2477
|
-
value: entry,
|
|
2478
|
-
};
|
|
2479
|
-
}
|
|
2480
|
-
if (isMarkupContent(entry)) {
|
|
2481
|
-
if (entry.kind === 'plaintext') {
|
|
2482
|
-
return {
|
|
2483
|
-
value: entry.value.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&'),
|
|
2484
|
-
};
|
|
2485
|
-
}
|
|
2486
|
-
return {
|
|
2487
|
-
value: entry.value,
|
|
2488
|
-
};
|
|
2489
|
-
}
|
|
2490
|
-
return { value: '```' + entry.value + '\n' + entry.value + '\n```\n' };
|
|
2491
|
-
}
|
|
2492
|
-
function toMarkedStringArray(contents) {
|
|
2493
|
-
if (!contents) {
|
|
2494
|
-
return void 0;
|
|
2495
|
-
}
|
|
2496
|
-
if (Array.isArray(contents)) {
|
|
2497
|
-
return contents.map(toMarkdownString);
|
|
2498
|
-
}
|
|
2499
|
-
return [toMarkdownString(contents)];
|
|
2500
|
-
}
|
|
2501
|
-
// --- definition ------
|
|
2502
|
-
function toLocation(location) {
|
|
2503
|
-
return {
|
|
2504
|
-
uri: Uri.parse(location.uri),
|
|
2505
|
-
range: toRange(location.range),
|
|
2506
|
-
};
|
|
2507
|
-
}
|
|
2508
|
-
var DefinitionAdapter = /** @class */ (function () {
|
|
2509
|
-
function DefinitionAdapter(_worker) {
|
|
2510
|
-
this._worker = _worker;
|
|
2511
|
-
}
|
|
2512
|
-
DefinitionAdapter.prototype.provideDefinition = function (model, position, token) {
|
|
2513
|
-
var resource = model.uri;
|
|
2514
|
-
return this._worker(resource)
|
|
2515
|
-
.then(function (worker) {
|
|
2516
|
-
return worker.findDefinition(resource.toString(), fromPosition(position));
|
|
2517
|
-
})
|
|
2518
|
-
.then(function (definition) {
|
|
2519
|
-
if (!definition || definition.length == 0) {
|
|
2520
|
-
return;
|
|
2521
|
-
}
|
|
2522
|
-
return [toLocation(definition[0])];
|
|
2523
|
-
});
|
|
2524
|
-
};
|
|
2525
|
-
return DefinitionAdapter;
|
|
2526
|
-
}());
|
|
2527
|
-
exports.DefinitionAdapter = DefinitionAdapter;
|
|
2528
|
-
// --- references ------
|
|
2529
|
-
var ReferenceAdapter = /** @class */ (function () {
|
|
2530
|
-
function ReferenceAdapter(_worker) {
|
|
2531
|
-
this._worker = _worker;
|
|
2532
|
-
}
|
|
2533
|
-
ReferenceAdapter.prototype.provideReferences = function (model, position, context, token) {
|
|
2534
|
-
var resource = model.uri;
|
|
2535
|
-
return this._worker(resource)
|
|
2536
|
-
.then(function (worker) {
|
|
2537
|
-
return worker.findReferences(resource.toString(), fromPosition(position));
|
|
2538
|
-
})
|
|
2539
|
-
.then(function (entries) {
|
|
2540
|
-
if (!entries) {
|
|
2541
|
-
return;
|
|
2542
|
-
}
|
|
2543
|
-
return entries.map(toLocation);
|
|
2544
|
-
});
|
|
2545
|
-
};
|
|
2546
|
-
return ReferenceAdapter;
|
|
2547
|
-
}());
|
|
2548
|
-
exports.ReferenceAdapter = ReferenceAdapter;
|
|
2549
|
-
// --- rename ------
|
|
2550
|
-
function toWorkspaceEdit(edit) {
|
|
2551
|
-
if (!edit || !edit.changes) {
|
|
2552
|
-
return void 0;
|
|
2553
|
-
}
|
|
2554
|
-
var resourceEdits = [];
|
|
2555
|
-
for (var uri in edit.changes) {
|
|
2556
|
-
var _uri = Uri.parse(uri);
|
|
2557
|
-
for (var _i = 0, _a = edit.changes[uri]; _i < _a.length; _i++) {
|
|
2558
|
-
var e = _a[_i];
|
|
2559
|
-
resourceEdits.push({
|
|
2560
|
-
resource: _uri,
|
|
2561
|
-
edit: {
|
|
2562
|
-
range: toRange(e.range),
|
|
2563
|
-
text: e.newText,
|
|
2564
|
-
},
|
|
2565
|
-
});
|
|
2566
|
-
}
|
|
2567
|
-
}
|
|
2568
|
-
return {
|
|
2569
|
-
edits: resourceEdits,
|
|
2570
|
-
};
|
|
2571
|
-
}
|
|
2572
|
-
var RenameAdapter = /** @class */ (function () {
|
|
2573
|
-
function RenameAdapter(_worker) {
|
|
2574
|
-
this._worker = _worker;
|
|
2575
|
-
}
|
|
2576
|
-
RenameAdapter.prototype.provideRenameEdits = function (model, position, newName, token) {
|
|
2577
|
-
var resource = model.uri;
|
|
2578
|
-
return this._worker(resource)
|
|
2579
|
-
.then(function (worker) {
|
|
2580
|
-
return worker.doRename(resource.toString(), fromPosition(position), newName);
|
|
2581
|
-
})
|
|
2582
|
-
.then(function (edit) {
|
|
2583
|
-
return toWorkspaceEdit(edit);
|
|
2584
|
-
});
|
|
2585
|
-
};
|
|
2586
|
-
return RenameAdapter;
|
|
2587
|
-
}());
|
|
2588
|
-
exports.RenameAdapter = RenameAdapter;
|
|
2589
|
-
// --- document symbols ------
|
|
2590
|
-
function toSymbolKind(kind) {
|
|
2591
|
-
var mKind = monaco.languages.SymbolKind;
|
|
2592
|
-
switch (kind) {
|
|
2593
|
-
case ls.SymbolKind.File:
|
|
2594
|
-
return mKind.Array;
|
|
2595
|
-
case ls.SymbolKind.Module:
|
|
2596
|
-
return mKind.Module;
|
|
2597
|
-
case ls.SymbolKind.Namespace:
|
|
2598
|
-
return mKind.Namespace;
|
|
2599
|
-
case ls.SymbolKind.Package:
|
|
2600
|
-
return mKind.Package;
|
|
2601
|
-
case ls.SymbolKind.Class:
|
|
2602
|
-
return mKind.Class;
|
|
2603
|
-
case ls.SymbolKind.Method:
|
|
2604
|
-
return mKind.Method;
|
|
2605
|
-
case ls.SymbolKind.Property:
|
|
2606
|
-
return mKind.Property;
|
|
2607
|
-
case ls.SymbolKind.Field:
|
|
2608
|
-
return mKind.Field;
|
|
2609
|
-
case ls.SymbolKind.Constructor:
|
|
2610
|
-
return mKind.Constructor;
|
|
2611
|
-
case ls.SymbolKind.Enum:
|
|
2612
|
-
return mKind.Enum;
|
|
2613
|
-
case ls.SymbolKind.Interface:
|
|
2614
|
-
return mKind.Interface;
|
|
2615
|
-
case ls.SymbolKind.Function:
|
|
2616
|
-
return mKind.Function;
|
|
2617
|
-
case ls.SymbolKind.Variable:
|
|
2618
|
-
return mKind.Variable;
|
|
2619
|
-
case ls.SymbolKind.Constant:
|
|
2620
|
-
return mKind.Constant;
|
|
2621
|
-
case ls.SymbolKind.String:
|
|
2622
|
-
return mKind.String;
|
|
2623
|
-
case ls.SymbolKind.Number:
|
|
2624
|
-
return mKind.Number;
|
|
2625
|
-
case ls.SymbolKind.Boolean:
|
|
2626
|
-
return mKind.Boolean;
|
|
2627
|
-
case ls.SymbolKind.Array:
|
|
2628
|
-
return mKind.Array;
|
|
2629
|
-
}
|
|
2630
|
-
return mKind.Function;
|
|
2631
|
-
}
|
|
2632
|
-
// --- formatting -----
|
|
2633
|
-
var DocumentFormatAdapter = /** @class */ (function () {
|
|
2634
|
-
function DocumentFormatAdapter(_worker) {
|
|
2635
|
-
this._worker = _worker;
|
|
2636
|
-
}
|
|
2637
|
-
DocumentFormatAdapter.prototype.provideDocumentFormattingEdits = function (model, options, token) {
|
|
2638
|
-
var resource = model.uri;
|
|
2639
|
-
return this._worker(resource).then(function (worker) {
|
|
2640
|
-
return worker.doDocumentFormat(resource.toString()).then(function (edits) { return edits.map(function (edit) { return toTextEdit(edit); }); });
|
|
2641
|
-
});
|
|
2642
|
-
};
|
|
2643
|
-
return DocumentFormatAdapter;
|
|
2644
|
-
}());
|
|
2645
|
-
exports.DocumentFormatAdapter = DocumentFormatAdapter;
|
|
2646
|
-
var FormatAdapter = /** @class */ (function () {
|
|
2647
|
-
function FormatAdapter(_worker) {
|
|
2648
|
-
this._worker = _worker;
|
|
2649
|
-
}
|
|
2650
|
-
FormatAdapter.prototype.provideDocumentRangeFormattingEdits = function (model, range, options, token) {
|
|
2651
|
-
var resource = model.uri;
|
|
2652
|
-
return this._worker(resource).then(function (worker) {
|
|
2653
|
-
return worker
|
|
2654
|
-
.doRangeFormat(resource.toString(), fromRange(range))
|
|
2655
|
-
.then(function (edits) { return edits.map(function (edit) { return toTextEdit(edit); }); });
|
|
2656
|
-
});
|
|
2657
|
-
};
|
|
2658
|
-
return FormatAdapter;
|
|
2659
|
-
}());
|
|
2660
|
-
exports.FormatAdapter = FormatAdapter;
|
|
2661
|
-
// --- Folding ---
|
|
2662
|
-
var FoldingAdapter = /** @class */ (function () {
|
|
2663
|
-
function FoldingAdapter(_worker) {
|
|
2664
|
-
this._worker = _worker;
|
|
2665
|
-
}
|
|
2666
|
-
FoldingAdapter.prototype.provideFoldingRanges = function (model, context, token) {
|
|
2667
|
-
var resource = model.uri;
|
|
2668
|
-
return this._worker(resource).then(function (worker) {
|
|
2669
|
-
return worker
|
|
2670
|
-
.doFolding(resource.toString())
|
|
2671
|
-
.then(function (foldingRanges) {
|
|
2672
|
-
return foldingRanges.map(function (range) { return toFoldingRange(range); });
|
|
2673
|
-
});
|
|
2674
|
-
});
|
|
2675
|
-
};
|
|
2676
|
-
return FoldingAdapter;
|
|
2677
|
-
}());
|
|
2678
|
-
exports.FoldingAdapter = FoldingAdapter;
|
|
2679
|
-
function toFoldingRange(range) {
|
|
2680
|
-
return {
|
|
2681
|
-
start: range.startLine + 1,
|
|
2682
|
-
end: range.endLine + 1,
|
|
2683
|
-
kind: monaco.languages.FoldingRangeKind.Region,
|
|
2684
|
-
};
|
|
2685
|
-
}
|
|
2686
|
-
// --- hover ------
|
|
2687
|
-
var HoverAdapter = /** @class */ (function () {
|
|
2688
|
-
function HoverAdapter(_worker) {
|
|
2689
|
-
this._worker = _worker;
|
|
2690
|
-
}
|
|
2691
|
-
HoverAdapter.prototype.provideHover = function (model, position, token) {
|
|
2692
|
-
var resource = model.uri;
|
|
2693
|
-
return this._worker(resource)
|
|
2694
|
-
.then(function (worker) {
|
|
2695
|
-
return worker.doHover(resource.toString(), fromPosition(position));
|
|
2696
|
-
})
|
|
2697
|
-
.then(function (info) {
|
|
2698
|
-
if (!info) {
|
|
2699
|
-
return;
|
|
2700
|
-
}
|
|
2701
|
-
return {
|
|
2702
|
-
range: toRange(info.range),
|
|
2703
|
-
contents: toMarkedStringArray(info.contents),
|
|
2704
|
-
};
|
|
2705
|
-
});
|
|
2706
|
-
};
|
|
2707
|
-
return HoverAdapter;
|
|
2708
|
-
}());
|
|
2709
|
-
exports.HoverAdapter = HoverAdapter;
|
|
2710
|
-
});
|
|
1874
|
+
define('vs/language/kusto/languageFeatures',["require", "exports", "vscode-languageserver-types", "lodash"], function (require, exports, ls, _) {
|
|
1875
|
+
"use strict";
|
|
1876
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1877
|
+
exports.HoverAdapter = exports.FoldingAdapter = exports.FormatAdapter = exports.DocumentFormatAdapter = exports.RenameAdapter = exports.ReferenceAdapter = exports.DefinitionAdapter = exports.CompletionAdapter = exports.ColorizationAdapter = exports.DiagnosticsAdapter = void 0;
|
|
1878
|
+
var Uri = monaco.Uri;
|
|
1879
|
+
var Range = monaco.Range;
|
|
1880
|
+
var ClassificationKind = Kusto.Language.Editor.ClassificationKind;
|
|
1881
|
+
// --- diagnostics ---
|
|
1882
|
+
var DiagnosticsAdapter = /** @class */ (function () {
|
|
1883
|
+
function DiagnosticsAdapter(_monacoInstance, _languageId, _worker, defaults, onSchemaChange) {
|
|
1884
|
+
var _this = this;
|
|
1885
|
+
this._monacoInstance = _monacoInstance;
|
|
1886
|
+
this._languageId = _languageId;
|
|
1887
|
+
this._worker = _worker;
|
|
1888
|
+
this.defaults = defaults;
|
|
1889
|
+
this._disposables = [];
|
|
1890
|
+
this._contentListener = Object.create(null);
|
|
1891
|
+
this._configurationListener = Object.create(null);
|
|
1892
|
+
this._schemaListener = Object.create(null);
|
|
1893
|
+
var onModelAdd = function (model) {
|
|
1894
|
+
var modeId = model.getModeId();
|
|
1895
|
+
if (modeId !== _this._languageId) {
|
|
1896
|
+
return;
|
|
1897
|
+
}
|
|
1898
|
+
var debouncedValidation = _.debounce(function (intervals) { return _this._doValidate(model, modeId, intervals); }, 500);
|
|
1899
|
+
_this._contentListener[model.uri.toString()] = model.onDidChangeContent(function (e) {
|
|
1900
|
+
var intervalsToValidate = changeEventToIntervals(e);
|
|
1901
|
+
debouncedValidation(intervalsToValidate);
|
|
1902
|
+
});
|
|
1903
|
+
_this._configurationListener[model.uri.toString()] = _this.defaults.onDidChange(function () {
|
|
1904
|
+
self.setTimeout(function () { return _this._doValidate(model, modeId, []); }, 0);
|
|
1905
|
+
});
|
|
1906
|
+
_this._schemaListener[model.uri.toString()] = onSchemaChange(function () {
|
|
1907
|
+
self.setTimeout(function () { return _this._doValidate(model, modeId, []); }, 0);
|
|
1908
|
+
});
|
|
1909
|
+
};
|
|
1910
|
+
var onModelRemoved = function (model) {
|
|
1911
|
+
_this._monacoInstance.editor.setModelMarkers(model, _this._languageId, []);
|
|
1912
|
+
var uriStr = model.uri.toString();
|
|
1913
|
+
var contentListener = _this._contentListener[uriStr];
|
|
1914
|
+
if (contentListener) {
|
|
1915
|
+
contentListener.dispose();
|
|
1916
|
+
delete _this._contentListener[uriStr];
|
|
1917
|
+
}
|
|
1918
|
+
var configurationListener = _this._configurationListener[uriStr];
|
|
1919
|
+
if (configurationListener) {
|
|
1920
|
+
configurationListener.dispose();
|
|
1921
|
+
delete _this._configurationListener[uriStr];
|
|
1922
|
+
}
|
|
1923
|
+
var schemaListener = _this._schemaListener[uriStr];
|
|
1924
|
+
if (schemaListener) {
|
|
1925
|
+
schemaListener.dispose();
|
|
1926
|
+
delete _this._schemaListener[uriStr];
|
|
1927
|
+
}
|
|
1928
|
+
};
|
|
1929
|
+
this._disposables.push(this._monacoInstance.editor.onDidCreateModel(onModelAdd));
|
|
1930
|
+
this._disposables.push(this._monacoInstance.editor.onWillDisposeModel(onModelRemoved));
|
|
1931
|
+
this._disposables.push(this._monacoInstance.editor.onDidChangeModelLanguage(function (event) {
|
|
1932
|
+
onModelRemoved(event.model);
|
|
1933
|
+
onModelAdd(event.model);
|
|
1934
|
+
}));
|
|
1935
|
+
this._disposables.push({
|
|
1936
|
+
dispose: function () {
|
|
1937
|
+
for (var key in _this._contentListener) {
|
|
1938
|
+
_this._contentListener[key].dispose();
|
|
1939
|
+
}
|
|
1940
|
+
},
|
|
1941
|
+
});
|
|
1942
|
+
this._monacoInstance.editor.getModels().forEach(onModelAdd);
|
|
1943
|
+
}
|
|
1944
|
+
DiagnosticsAdapter.prototype.dispose = function () {
|
|
1945
|
+
this._disposables.forEach(function (d) { return d && d.dispose(); });
|
|
1946
|
+
this._disposables = [];
|
|
1947
|
+
};
|
|
1948
|
+
DiagnosticsAdapter.prototype._doValidate = function (model, languageId, intervals) {
|
|
1949
|
+
var _this = this;
|
|
1950
|
+
if (model.isDisposed()) {
|
|
1951
|
+
return;
|
|
1952
|
+
}
|
|
1953
|
+
var resource = model.uri;
|
|
1954
|
+
var versionNumberBefore = model.getVersionId();
|
|
1955
|
+
this._worker(resource)
|
|
1956
|
+
.then(function (worker) {
|
|
1957
|
+
return worker.doValidation(resource.toString(), intervals);
|
|
1958
|
+
})
|
|
1959
|
+
.then(function (diagnostics) {
|
|
1960
|
+
var newModel = _this._monacoInstance.editor.getModel(resource);
|
|
1961
|
+
var versionId = newModel.getVersionId();
|
|
1962
|
+
if (versionId !== versionNumberBefore) {
|
|
1963
|
+
return;
|
|
1964
|
+
}
|
|
1965
|
+
var markers = diagnostics.map(function (d) { return toDiagnostics(resource, d); });
|
|
1966
|
+
var model = _this._monacoInstance.editor.getModel(resource);
|
|
1967
|
+
var oldDecorations = model.getAllDecorations()
|
|
1968
|
+
.filter(function (decoration) { return decoration.options.className == "squiggly-error"; })
|
|
1969
|
+
.map(function (decoration) { return decoration.id; });
|
|
1970
|
+
if (model && model.getModeId() === languageId) {
|
|
1971
|
+
var syntaxErrorAsMarkDown = _this.defaults.languageSettings.syntaxErrorAsMarkDown;
|
|
1972
|
+
if (!syntaxErrorAsMarkDown || !syntaxErrorAsMarkDown.enableSyntaxErrorAsMarkDown) {
|
|
1973
|
+
// Remove previous syntax error decorations and set the new markers (for example, when disabling syntaxErrorAsMarkDown after it was enabled)
|
|
1974
|
+
model.deltaDecorations(oldDecorations, []);
|
|
1975
|
+
_this._monacoInstance.editor.setModelMarkers(model, languageId, markers);
|
|
1976
|
+
}
|
|
1977
|
+
else {
|
|
1978
|
+
// Add custom popup for syntax error: icon, header and message as markdown
|
|
1979
|
+
var header = syntaxErrorAsMarkDown.header ? "**" + syntaxErrorAsMarkDown.header + "** \n\n" : "";
|
|
1980
|
+
var icon = syntaxErrorAsMarkDown.icon ? "" : "";
|
|
1981
|
+
var popupErrorHoverHeaderMessage_1 = icon + " " + header;
|
|
1982
|
+
var newDecorations = markers.map(function (marker) {
|
|
1983
|
+
return {
|
|
1984
|
+
range: {
|
|
1985
|
+
startLineNumber: marker.startLineNumber,
|
|
1986
|
+
startColumn: marker.startColumn,
|
|
1987
|
+
endLineNumber: marker.endLineNumber,
|
|
1988
|
+
endColumn: marker.endColumn
|
|
1989
|
+
},
|
|
1990
|
+
options: {
|
|
1991
|
+
hoverMessage: {
|
|
1992
|
+
value: popupErrorHoverHeaderMessage_1 + marker.message
|
|
1993
|
+
},
|
|
1994
|
+
className: "squiggly-error",
|
|
1995
|
+
zIndex: 100,
|
|
1996
|
+
overviewRuler: {
|
|
1997
|
+
// The color indication on the right ruler
|
|
1998
|
+
color: "rgb(255, 18, 18, 0.7)",
|
|
1999
|
+
position: monaco.editor.OverviewRulerLane.Right
|
|
2000
|
+
},
|
|
2001
|
+
minimap: {
|
|
2002
|
+
color: "rgb(255, 18, 18, 0.7)",
|
|
2003
|
+
position: monaco.editor.MinimapPosition.Inline
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
};
|
|
2007
|
+
});
|
|
2008
|
+
var oldMarkers = monaco.editor.getModelMarkers({
|
|
2009
|
+
owner: languageId,
|
|
2010
|
+
resource: resource
|
|
2011
|
+
}).filter(function (marker) { return marker.severity == monaco.MarkerSeverity.Error; });
|
|
2012
|
+
if (oldMarkers && oldMarkers.length > 0) {
|
|
2013
|
+
// In case there were previous markers, remove their decorations (for example, when enabling syntaxErrorAsMarkDown after it was disabled)
|
|
2014
|
+
oldDecorations = [];
|
|
2015
|
+
// Remove previous markers
|
|
2016
|
+
_this._monacoInstance.editor.setModelMarkers(model, languageId, []);
|
|
2017
|
+
}
|
|
2018
|
+
// Remove previous syntax error decorations and set the new decorations
|
|
2019
|
+
model.deltaDecorations(oldDecorations, newDecorations);
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2022
|
+
})
|
|
2023
|
+
.then(undefined, function (err) {
|
|
2024
|
+
console.error(err);
|
|
2025
|
+
});
|
|
2026
|
+
};
|
|
2027
|
+
return DiagnosticsAdapter;
|
|
2028
|
+
}());
|
|
2029
|
+
exports.DiagnosticsAdapter = DiagnosticsAdapter;
|
|
2030
|
+
function changeEventToIntervals(e) {
|
|
2031
|
+
return e.changes.map(function (change) { return ({
|
|
2032
|
+
start: change.rangeOffset,
|
|
2033
|
+
end: change.rangeOffset + change.text.length,
|
|
2034
|
+
}); });
|
|
2035
|
+
}
|
|
2036
|
+
function toSeverity(lsSeverity) {
|
|
2037
|
+
switch (lsSeverity) {
|
|
2038
|
+
case ls.DiagnosticSeverity.Error:
|
|
2039
|
+
return monaco.MarkerSeverity.Error;
|
|
2040
|
+
case ls.DiagnosticSeverity.Warning:
|
|
2041
|
+
return monaco.MarkerSeverity.Warning;
|
|
2042
|
+
case ls.DiagnosticSeverity.Information:
|
|
2043
|
+
return monaco.MarkerSeverity.Info;
|
|
2044
|
+
case ls.DiagnosticSeverity.Hint:
|
|
2045
|
+
return monaco.MarkerSeverity.Hint;
|
|
2046
|
+
default:
|
|
2047
|
+
return monaco.MarkerSeverity.Info;
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
function toDiagnostics(resource, diag) {
|
|
2051
|
+
var code = typeof diag.code === 'number' ? String(diag.code) : diag.code;
|
|
2052
|
+
return {
|
|
2053
|
+
severity: toSeverity(diag.severity),
|
|
2054
|
+
startLineNumber: diag.range.start.line + 1,
|
|
2055
|
+
startColumn: diag.range.start.character + 1,
|
|
2056
|
+
endLineNumber: diag.range.end.line + 1,
|
|
2057
|
+
endColumn: diag.range.end.character + 1,
|
|
2058
|
+
message: diag.message,
|
|
2059
|
+
code: code,
|
|
2060
|
+
source: diag.source,
|
|
2061
|
+
};
|
|
2062
|
+
}
|
|
2063
|
+
// --- colorization ---
|
|
2064
|
+
function fromIRange(range) {
|
|
2065
|
+
if (!range) {
|
|
2066
|
+
return undefined;
|
|
2067
|
+
}
|
|
2068
|
+
if (range instanceof monaco.Range) {
|
|
2069
|
+
return { start: fromPosition(range.getStartPosition()), end: fromPosition(range.getEndPosition()) };
|
|
2070
|
+
}
|
|
2071
|
+
var startLineNumber = range.startLineNumber, startColumn = range.startColumn, endLineNumber = range.endLineNumber, endColumn = range.endColumn;
|
|
2072
|
+
range = new monaco.Range(startLineNumber, startColumn, endLineNumber, endColumn);
|
|
2073
|
+
}
|
|
2074
|
+
// commented here is the color definitions are were defined by v1 intellisense terminology:
|
|
2075
|
+
// { token: 'comment', foreground: '008000' }, // CommentToken Green
|
|
2076
|
+
// { token: 'variable.predefined', foreground: '800080' }, // CalculatedColumnToken Purple
|
|
2077
|
+
// { token: 'function', foreground: '0000FF' }, // FunctionNameToken Blue
|
|
2078
|
+
// { token: 'operator.sql', foreground: 'FF4500' }, // OperatorToken OrangeRed (now changed to darker color CC3700 because wasn't accessible)
|
|
2079
|
+
// { token: 'string', foreground: 'B22222' }, // StringLiteralToken Firebrick
|
|
2080
|
+
// { token: 'operator.scss', foreground: '0000FF' }, // SubOperatorToken Blue
|
|
2081
|
+
// { token: 'variable', foreground: 'C71585' }, // TableColumnToken MediumVioletRed
|
|
2082
|
+
// { token: 'variable.parameter', foreground: '9932CC' }, // TableToken DarkOrchid
|
|
2083
|
+
// { token: '', foreground: '000000' }, // UnknownToken, PlainTextToken Black
|
|
2084
|
+
// { token: 'type', foreground: '0000FF' }, // DataTypeToken Blue
|
|
2085
|
+
// { token: 'tag', foreground: '0000FF' }, // ControlCommandToken Blue
|
|
2086
|
+
// { token: 'annotation', foreground: '2B91AF' }, // QueryParametersToken FF2B91AF
|
|
2087
|
+
// { token: 'keyword', foreground: '0000FF' }, // CslCommandToken, PluginToken Blue
|
|
2088
|
+
// { token: 'number', foreground: '191970' }, // LetVariablesToken MidnightBlue
|
|
2089
|
+
// { token: 'annotation', foreground: '9400D3' }, // ClientDirectiveToken DarkViolet
|
|
2090
|
+
// { token: 'invalid', background: 'cd3131' },
|
|
2091
|
+
var classificationToColorLight = {
|
|
2092
|
+
Column: 'C71585',
|
|
2093
|
+
Comment: '008000',
|
|
2094
|
+
Database: 'C71585',
|
|
2095
|
+
Function: '0000FF',
|
|
2096
|
+
Identifier: '000000',
|
|
2097
|
+
Keyword: '0000FF',
|
|
2098
|
+
Literal: 'B22222',
|
|
2099
|
+
ScalarOperator: '000000',
|
|
2100
|
+
MaterializedView: 'C71585',
|
|
2101
|
+
MathOperator: '000000',
|
|
2102
|
+
Command: '0000FF',
|
|
2103
|
+
Parameter: '2B91AF',
|
|
2104
|
+
PlainText: '000000',
|
|
2105
|
+
Punctuation: '000000',
|
|
2106
|
+
QueryOperator: 'CC3700',
|
|
2107
|
+
QueryParameter: 'CC3700',
|
|
2108
|
+
StringLiteral: 'B22222',
|
|
2109
|
+
Table: 'C71585',
|
|
2110
|
+
Type: '0000FF',
|
|
2111
|
+
Variable: '191970',
|
|
2112
|
+
Directive: '9400D3',
|
|
2113
|
+
ClientParameter: 'b5cea8',
|
|
2114
|
+
SchemaMember: 'C71585',
|
|
2115
|
+
SignatureParameter: '2B91AF',
|
|
2116
|
+
Option: '000000',
|
|
2117
|
+
};
|
|
2118
|
+
var classificationToColorDark = {
|
|
2119
|
+
Column: '4ec9b0',
|
|
2120
|
+
Comment: '608B4E',
|
|
2121
|
+
Database: 'c586c0',
|
|
2122
|
+
Function: 'dcdcaa',
|
|
2123
|
+
Identifier: 'd4d4d4',
|
|
2124
|
+
Keyword: '569cd6',
|
|
2125
|
+
Literal: 'ce9178',
|
|
2126
|
+
ScalarOperator: 'd4d4d4',
|
|
2127
|
+
MaterializedView: 'c586c0',
|
|
2128
|
+
MathOperator: 'd4d4d4',
|
|
2129
|
+
Command: 'd4d4d4',
|
|
2130
|
+
Parameter: '2B91AF',
|
|
2131
|
+
PlainText: 'd4d4d4',
|
|
2132
|
+
Punctuation: 'd4d4d4',
|
|
2133
|
+
QueryOperator: '9cdcfe',
|
|
2134
|
+
QueryParameter: '9cdcfe',
|
|
2135
|
+
StringLiteral: 'ce9178',
|
|
2136
|
+
Table: 'c586c0',
|
|
2137
|
+
Type: '569cd6',
|
|
2138
|
+
Variable: 'd7ba7d',
|
|
2139
|
+
Directive: 'b5cea8',
|
|
2140
|
+
ClientParameter: 'b5cea8',
|
|
2141
|
+
SchemaMember: '4ec9b0',
|
|
2142
|
+
SignatureParameter: '2B91AF',
|
|
2143
|
+
Option: 'd4d4d4',
|
|
2144
|
+
};
|
|
2145
|
+
var ColorizationAdapter = /** @class */ (function () {
|
|
2146
|
+
function ColorizationAdapter(_monacoInstance, _languageId, _worker, defaults, onSchemaChange) {
|
|
2147
|
+
var _this = this;
|
|
2148
|
+
this._monacoInstance = _monacoInstance;
|
|
2149
|
+
this._languageId = _languageId;
|
|
2150
|
+
this._worker = _worker;
|
|
2151
|
+
this._disposables = [];
|
|
2152
|
+
this._contentListener = Object.create(null);
|
|
2153
|
+
this._configurationListener = Object.create(null);
|
|
2154
|
+
this._schemaListener = Object.create(null);
|
|
2155
|
+
this.decorations = [];
|
|
2156
|
+
injectCss();
|
|
2157
|
+
var onModelAdd = function (model) {
|
|
2158
|
+
var modeId = model.getModeId();
|
|
2159
|
+
if (modeId !== _this._languageId) {
|
|
2160
|
+
return;
|
|
2161
|
+
}
|
|
2162
|
+
var debouncedColorization = _.debounce(function (intervals) { return _this._doColorization(model, modeId, intervals); }, 500);
|
|
2163
|
+
var handle;
|
|
2164
|
+
_this._contentListener[model.uri.toString()] = model.onDidChangeContent(function (e) {
|
|
2165
|
+
// Changes are represented as a range in doc before change, plus the text that it was replaced with.
|
|
2166
|
+
// We are interested in the range _after_ the change (since that's what we need to colorize).
|
|
2167
|
+
// folowing logic calculates that.
|
|
2168
|
+
var intervalsToColorize = changeEventToIntervals(e);
|
|
2169
|
+
debouncedColorization(intervalsToColorize);
|
|
2170
|
+
});
|
|
2171
|
+
_this._configurationListener[model.uri.toString()] = defaults.onDidChange(function () {
|
|
2172
|
+
self.setTimeout(function () { return _this._doColorization(model, modeId, []); }, 0);
|
|
2173
|
+
});
|
|
2174
|
+
_this._schemaListener[model.uri.toString()] = onSchemaChange(function () {
|
|
2175
|
+
self.setTimeout(function () { return _this._doColorization(model, modeId, []); }, 0);
|
|
2176
|
+
});
|
|
2177
|
+
};
|
|
2178
|
+
var onModelRemoved = function (model) {
|
|
2179
|
+
model.deltaDecorations(_this.decorations, []);
|
|
2180
|
+
var uriStr = model.uri.toString();
|
|
2181
|
+
var contentListener = _this._contentListener[uriStr];
|
|
2182
|
+
if (contentListener) {
|
|
2183
|
+
contentListener.dispose();
|
|
2184
|
+
delete _this._contentListener[uriStr];
|
|
2185
|
+
}
|
|
2186
|
+
var configurationListener = _this._configurationListener[uriStr];
|
|
2187
|
+
if (configurationListener) {
|
|
2188
|
+
configurationListener.dispose();
|
|
2189
|
+
delete _this._configurationListener[uriStr];
|
|
2190
|
+
}
|
|
2191
|
+
var schemaListener = _this._configurationListener[uriStr];
|
|
2192
|
+
if (schemaListener) {
|
|
2193
|
+
schemaListener.dispose();
|
|
2194
|
+
delete _this._schemaListener[uriStr];
|
|
2195
|
+
}
|
|
2196
|
+
};
|
|
2197
|
+
this._disposables.push(this._monacoInstance.editor.onDidCreateModel(onModelAdd));
|
|
2198
|
+
this._disposables.push(this._monacoInstance.editor.onWillDisposeModel(onModelRemoved));
|
|
2199
|
+
this._disposables.push(this._monacoInstance.editor.onDidChangeModelLanguage(function (event) {
|
|
2200
|
+
onModelRemoved(event.model);
|
|
2201
|
+
onModelAdd(event.model);
|
|
2202
|
+
}));
|
|
2203
|
+
this._disposables.push({
|
|
2204
|
+
dispose: function () {
|
|
2205
|
+
for (var key in _this._contentListener) {
|
|
2206
|
+
_this._contentListener[key].dispose();
|
|
2207
|
+
}
|
|
2208
|
+
},
|
|
2209
|
+
});
|
|
2210
|
+
this._monacoInstance.editor.getModels().forEach(onModelAdd);
|
|
2211
|
+
}
|
|
2212
|
+
ColorizationAdapter.prototype.dispose = function () {
|
|
2213
|
+
this._disposables.forEach(function (d) { return d && d.dispose(); });
|
|
2214
|
+
this._disposables = [];
|
|
2215
|
+
};
|
|
2216
|
+
/**
|
|
2217
|
+
* Return true if the range doesn't intersect any of the line ranges.
|
|
2218
|
+
* @param range Range
|
|
2219
|
+
* @param impactedLineRanges an array of line ranges
|
|
2220
|
+
*/
|
|
2221
|
+
ColorizationAdapter.prototype._rangeDoesNotIntersectAny = function (range, impactedLineRanges) {
|
|
2222
|
+
return impactedLineRanges.every(function (lineRange) {
|
|
2223
|
+
return range.startLineNumber > lineRange.lastImpactedLine || range.endLineNumber < lineRange.firstImpactedLine;
|
|
2224
|
+
});
|
|
2225
|
+
};
|
|
2226
|
+
ColorizationAdapter.prototype._doColorization = function (model, languageId, intervals) {
|
|
2227
|
+
var _this = this;
|
|
2228
|
+
if (model.isDisposed()) {
|
|
2229
|
+
return;
|
|
2230
|
+
}
|
|
2231
|
+
var resource = model.uri;
|
|
2232
|
+
var versionNumberBeforeColorization = model.getVersionId();
|
|
2233
|
+
this._worker(resource)
|
|
2234
|
+
.then(function (worker) {
|
|
2235
|
+
return worker.doColorization(resource.toString(), intervals);
|
|
2236
|
+
})
|
|
2237
|
+
.then(function (colorizationRanges) {
|
|
2238
|
+
var newModel = _this._monacoInstance.editor.getModel(model.uri);
|
|
2239
|
+
var versionId = newModel.getVersionId();
|
|
2240
|
+
// don't colorize an older version of the document.
|
|
2241
|
+
if (versionId !== versionNumberBeforeColorization) {
|
|
2242
|
+
return;
|
|
2243
|
+
}
|
|
2244
|
+
var decorationRanges = colorizationRanges.map(function (colorizationRange) {
|
|
2245
|
+
var decorations = colorizationRange.classifications
|
|
2246
|
+
.map(function (classification) { return toDecoration(model, classification); })
|
|
2247
|
+
// The following line will prevent things that aren't going to be colorized anyway to get a CSS class.
|
|
2248
|
+
// This will prevent the case where the non-semantic colorizer already figured out that a keyword needs
|
|
2249
|
+
// to be colorized, but the outdated semantic colorizer still thinks it's a plain text and wants it colored
|
|
2250
|
+
// in black.
|
|
2251
|
+
.filter(function (d) {
|
|
2252
|
+
return d.options.inlineClassName !== 'PlainText' && d.options.inlineClassName != 'Identifier';
|
|
2253
|
+
});
|
|
2254
|
+
var firstImpactedLine = model.getPositionAt(colorizationRange.absoluteStart).lineNumber;
|
|
2255
|
+
var endPosition = model.getPositionAt(colorizationRange.absoluteEnd);
|
|
2256
|
+
// A token that ends in the first column of the next line is not considered to be part of that line.
|
|
2257
|
+
var lastImpactedLine = endPosition.column == 1 && endPosition.lineNumber > 1
|
|
2258
|
+
? endPosition.lineNumber - 1
|
|
2259
|
+
: endPosition.lineNumber;
|
|
2260
|
+
return { decorations: decorations, firstImpactedLine: firstImpactedLine, lastImpactedLine: lastImpactedLine };
|
|
2261
|
+
});
|
|
2262
|
+
// Compute the previous decorations we want to replace with the new ones.
|
|
2263
|
+
var oldDecorations = decorationRanges
|
|
2264
|
+
.map(function (range) {
|
|
2265
|
+
return model
|
|
2266
|
+
.getLinesDecorations(range.firstImpactedLine, range.lastImpactedLine)
|
|
2267
|
+
.filter(function (d) { return classificationToColorLight[d.options.inlineClassName]; }) // Don't delete any other decorations
|
|
2268
|
+
.map(function (d) { return d.id; });
|
|
2269
|
+
})
|
|
2270
|
+
.reduce(function (prev, curr) { return prev.concat(curr); }, []);
|
|
2271
|
+
// Flatten decoration groups to an array of decorations
|
|
2272
|
+
var newDecorations = decorationRanges.reduce(function (prev, next) { return prev.concat(next.decorations); }, []);
|
|
2273
|
+
if (model && model.getModeId() === languageId) {
|
|
2274
|
+
_this.decorations = model.deltaDecorations(oldDecorations, newDecorations);
|
|
2275
|
+
}
|
|
2276
|
+
})
|
|
2277
|
+
.then(undefined, function (err) {
|
|
2278
|
+
console.error(err);
|
|
2279
|
+
});
|
|
2280
|
+
};
|
|
2281
|
+
return ColorizationAdapter;
|
|
2282
|
+
}());
|
|
2283
|
+
exports.ColorizationAdapter = ColorizationAdapter;
|
|
2284
|
+
/**
|
|
2285
|
+
* Gets all keys of an enum (the string keys not the numeric values).
|
|
2286
|
+
* @param e Enum type
|
|
2287
|
+
*/
|
|
2288
|
+
function getEnumKeys(e) {
|
|
2289
|
+
return Object.keys(e).filter(function (k) { return typeof e[k] === 'number'; });
|
|
2290
|
+
}
|
|
2291
|
+
/**
|
|
2292
|
+
* Generates a mapping between ClassificationKind and color.
|
|
2293
|
+
*/
|
|
2294
|
+
function getClassificationColorTriplets() {
|
|
2295
|
+
var keys = getEnumKeys(ClassificationKind);
|
|
2296
|
+
var result = keys.map(function (key) { return ({
|
|
2297
|
+
classification: key,
|
|
2298
|
+
colorLight: classificationToColorLight[key],
|
|
2299
|
+
colorDark: classificationToColorDark[key],
|
|
2300
|
+
}); });
|
|
2301
|
+
return result;
|
|
2302
|
+
}
|
|
2303
|
+
/**
|
|
2304
|
+
* Returns a string which is a css describing all tokens and their colors.
|
|
2305
|
+
* looks a little bit something like this:
|
|
2306
|
+
*
|
|
2307
|
+
* .vs .Literal {color: '#000000';} .vs-dark .Literal {color: '#FFFFFF';}
|
|
2308
|
+
* .vs .Comment {color: '#111111';} .vs-dark .Comment {color: '#EEEEEE';}
|
|
2309
|
+
*/
|
|
2310
|
+
function getCssForClassification() {
|
|
2311
|
+
var classificationColorTriplets = getClassificationColorTriplets();
|
|
2312
|
+
var cssInnerHtml = classificationColorTriplets
|
|
2313
|
+
.map(function (pair) {
|
|
2314
|
+
return ".vs ." + pair.classification + " {color: #" + pair.colorLight + ";} .vs-dark ." + pair.classification + " {color: #" + pair.colorDark + ";}";
|
|
2315
|
+
})
|
|
2316
|
+
.join('\n');
|
|
2317
|
+
return cssInnerHtml;
|
|
2318
|
+
}
|
|
2319
|
+
/**
|
|
2320
|
+
* Inject a CSS sheet to the head of document, coloring kusto elements by classification.
|
|
2321
|
+
* TODO: make idempotent
|
|
2322
|
+
*/
|
|
2323
|
+
function injectCss() {
|
|
2324
|
+
var container = document.getElementsByTagName('head')[0];
|
|
2325
|
+
var style = document.createElement('style');
|
|
2326
|
+
style.type = 'text/css';
|
|
2327
|
+
style.media = 'screen';
|
|
2328
|
+
container.appendChild(style);
|
|
2329
|
+
ClassificationKind;
|
|
2330
|
+
style.innerHTML = getCssForClassification();
|
|
2331
|
+
}
|
|
2332
|
+
function toDecoration(model, classification) {
|
|
2333
|
+
var start = model.getPositionAt(classification.start);
|
|
2334
|
+
var end = model.getPositionAt(classification.start + classification.length);
|
|
2335
|
+
var range = new Range(start.lineNumber, start.column, end.lineNumber, end.column);
|
|
2336
|
+
var inlineClassName = ClassificationKind.$names[classification.kind];
|
|
2337
|
+
return {
|
|
2338
|
+
range: range,
|
|
2339
|
+
options: {
|
|
2340
|
+
inlineClassName: inlineClassName,
|
|
2341
|
+
stickiness: monaco.editor.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
|
|
2342
|
+
},
|
|
2343
|
+
};
|
|
2344
|
+
}
|
|
2345
|
+
// --- completion ------
|
|
2346
|
+
function fromPosition(position) {
|
|
2347
|
+
if (!position) {
|
|
2348
|
+
return void 0;
|
|
2349
|
+
}
|
|
2350
|
+
return { character: position.column - 1, line: position.lineNumber - 1 };
|
|
2351
|
+
}
|
|
2352
|
+
function fromRange(range) {
|
|
2353
|
+
if (!range) {
|
|
2354
|
+
return void 0;
|
|
2355
|
+
}
|
|
2356
|
+
return { start: fromPosition(range.getStartPosition()), end: fromPosition(range.getEndPosition()) };
|
|
2357
|
+
}
|
|
2358
|
+
function toRange(range) {
|
|
2359
|
+
if (!range) {
|
|
2360
|
+
return void 0;
|
|
2361
|
+
}
|
|
2362
|
+
return new Range(range.start.line + 1, range.start.character + 1, range.end.line + 1, range.end.character + 1);
|
|
2363
|
+
}
|
|
2364
|
+
function toCompletionItemKind(kind) {
|
|
2365
|
+
var mItemKind = monaco.languages.CompletionItemKind;
|
|
2366
|
+
switch (kind) {
|
|
2367
|
+
case ls.CompletionItemKind.Text:
|
|
2368
|
+
return mItemKind.Text;
|
|
2369
|
+
case ls.CompletionItemKind.Method:
|
|
2370
|
+
return mItemKind.Method;
|
|
2371
|
+
case ls.CompletionItemKind.Function:
|
|
2372
|
+
return mItemKind.Function;
|
|
2373
|
+
case ls.CompletionItemKind.Constructor:
|
|
2374
|
+
return mItemKind.Constructor;
|
|
2375
|
+
case ls.CompletionItemKind.Field:
|
|
2376
|
+
return mItemKind.Field;
|
|
2377
|
+
case ls.CompletionItemKind.Variable:
|
|
2378
|
+
return mItemKind.Variable;
|
|
2379
|
+
case ls.CompletionItemKind.Class:
|
|
2380
|
+
return mItemKind.Class;
|
|
2381
|
+
case ls.CompletionItemKind.Interface:
|
|
2382
|
+
return mItemKind.Interface;
|
|
2383
|
+
case ls.CompletionItemKind.Module:
|
|
2384
|
+
return mItemKind.Module;
|
|
2385
|
+
case ls.CompletionItemKind.Property:
|
|
2386
|
+
return mItemKind.Property;
|
|
2387
|
+
case ls.CompletionItemKind.Unit:
|
|
2388
|
+
return mItemKind.Unit;
|
|
2389
|
+
case ls.CompletionItemKind.Value:
|
|
2390
|
+
return mItemKind.Value;
|
|
2391
|
+
case ls.CompletionItemKind.Enum:
|
|
2392
|
+
return mItemKind.Enum;
|
|
2393
|
+
case ls.CompletionItemKind.Keyword:
|
|
2394
|
+
return mItemKind.Keyword;
|
|
2395
|
+
case ls.CompletionItemKind.Snippet:
|
|
2396
|
+
return mItemKind.Snippet;
|
|
2397
|
+
case ls.CompletionItemKind.Color:
|
|
2398
|
+
return mItemKind.Color;
|
|
2399
|
+
case ls.CompletionItemKind.File:
|
|
2400
|
+
return mItemKind.File;
|
|
2401
|
+
case ls.CompletionItemKind.Reference:
|
|
2402
|
+
return mItemKind.Reference;
|
|
2403
|
+
}
|
|
2404
|
+
return mItemKind.Property;
|
|
2405
|
+
}
|
|
2406
|
+
function toTextEdit(textEdit) {
|
|
2407
|
+
if (!textEdit) {
|
|
2408
|
+
return void 0;
|
|
2409
|
+
}
|
|
2410
|
+
return {
|
|
2411
|
+
range: toRange(textEdit.range),
|
|
2412
|
+
text: textEdit.newText,
|
|
2413
|
+
};
|
|
2414
|
+
}
|
|
2415
|
+
var CompletionAdapter = /** @class */ (function () {
|
|
2416
|
+
function CompletionAdapter(_worker, languageSettings) {
|
|
2417
|
+
this._worker = _worker;
|
|
2418
|
+
this.languageSettings = languageSettings;
|
|
2419
|
+
}
|
|
2420
|
+
Object.defineProperty(CompletionAdapter.prototype, "triggerCharacters", {
|
|
2421
|
+
get: function () {
|
|
2422
|
+
return [' '];
|
|
2423
|
+
},
|
|
2424
|
+
enumerable: false,
|
|
2425
|
+
configurable: true
|
|
2426
|
+
});
|
|
2427
|
+
CompletionAdapter.prototype.provideCompletionItems = function (model, position, context, token) {
|
|
2428
|
+
var wordInfo = model.getWordUntilPosition(position);
|
|
2429
|
+
var wordRange = new Range(position.lineNumber, wordInfo.startColumn, position.lineNumber, wordInfo.endColumn);
|
|
2430
|
+
var resource = model.uri;
|
|
2431
|
+
var onDidProvideCompletionItems = this.languageSettings
|
|
2432
|
+
.onDidProvideCompletionItems;
|
|
2433
|
+
return this._worker(resource)
|
|
2434
|
+
.then(function (worker) {
|
|
2435
|
+
return worker.doComplete(resource.toString(), fromPosition(position));
|
|
2436
|
+
})
|
|
2437
|
+
.then(function (info) { return (onDidProvideCompletionItems ? onDidProvideCompletionItems(info) : info); })
|
|
2438
|
+
.then(function (info) {
|
|
2439
|
+
if (!info) {
|
|
2440
|
+
return;
|
|
2441
|
+
}
|
|
2442
|
+
var items = info.items.map(function (entry) {
|
|
2443
|
+
var item = {
|
|
2444
|
+
label: entry.label,
|
|
2445
|
+
insertText: entry.insertText,
|
|
2446
|
+
sortText: entry.sortText,
|
|
2447
|
+
filterText: entry.filterText,
|
|
2448
|
+
documentation: entry.documentation,
|
|
2449
|
+
detail: entry.detail,
|
|
2450
|
+
range: wordRange,
|
|
2451
|
+
kind: toCompletionItemKind(entry.kind),
|
|
2452
|
+
};
|
|
2453
|
+
if (entry.textEdit) {
|
|
2454
|
+
item.range = toRange(entry.textEdit.range);
|
|
2455
|
+
item.insertText = entry.textEdit.newText;
|
|
2456
|
+
}
|
|
2457
|
+
if (entry.insertTextFormat === ls.InsertTextFormat.Snippet) {
|
|
2458
|
+
item.insertTextRules = monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet;
|
|
2459
|
+
}
|
|
2460
|
+
return item;
|
|
2461
|
+
});
|
|
2462
|
+
return {
|
|
2463
|
+
isIncomplete: info.isIncomplete,
|
|
2464
|
+
suggestions: items,
|
|
2465
|
+
};
|
|
2466
|
+
});
|
|
2467
|
+
};
|
|
2468
|
+
return CompletionAdapter;
|
|
2469
|
+
}());
|
|
2470
|
+
exports.CompletionAdapter = CompletionAdapter;
|
|
2471
|
+
function isMarkupContent(thing) {
|
|
2472
|
+
return thing && typeof thing === 'object' && typeof thing.kind === 'string';
|
|
2473
|
+
}
|
|
2474
|
+
function toMarkdownString(entry) {
|
|
2475
|
+
if (typeof entry === 'string') {
|
|
2476
|
+
return {
|
|
2477
|
+
value: entry,
|
|
2478
|
+
};
|
|
2479
|
+
}
|
|
2480
|
+
if (isMarkupContent(entry)) {
|
|
2481
|
+
if (entry.kind === 'plaintext') {
|
|
2482
|
+
return {
|
|
2483
|
+
value: entry.value.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&'),
|
|
2484
|
+
};
|
|
2485
|
+
}
|
|
2486
|
+
return {
|
|
2487
|
+
value: entry.value,
|
|
2488
|
+
};
|
|
2489
|
+
}
|
|
2490
|
+
return { value: '```' + entry.value + '\n' + entry.value + '\n```\n' };
|
|
2491
|
+
}
|
|
2492
|
+
function toMarkedStringArray(contents) {
|
|
2493
|
+
if (!contents) {
|
|
2494
|
+
return void 0;
|
|
2495
|
+
}
|
|
2496
|
+
if (Array.isArray(contents)) {
|
|
2497
|
+
return contents.map(toMarkdownString);
|
|
2498
|
+
}
|
|
2499
|
+
return [toMarkdownString(contents)];
|
|
2500
|
+
}
|
|
2501
|
+
// --- definition ------
|
|
2502
|
+
function toLocation(location) {
|
|
2503
|
+
return {
|
|
2504
|
+
uri: Uri.parse(location.uri),
|
|
2505
|
+
range: toRange(location.range),
|
|
2506
|
+
};
|
|
2507
|
+
}
|
|
2508
|
+
var DefinitionAdapter = /** @class */ (function () {
|
|
2509
|
+
function DefinitionAdapter(_worker) {
|
|
2510
|
+
this._worker = _worker;
|
|
2511
|
+
}
|
|
2512
|
+
DefinitionAdapter.prototype.provideDefinition = function (model, position, token) {
|
|
2513
|
+
var resource = model.uri;
|
|
2514
|
+
return this._worker(resource)
|
|
2515
|
+
.then(function (worker) {
|
|
2516
|
+
return worker.findDefinition(resource.toString(), fromPosition(position));
|
|
2517
|
+
})
|
|
2518
|
+
.then(function (definition) {
|
|
2519
|
+
if (!definition || definition.length == 0) {
|
|
2520
|
+
return;
|
|
2521
|
+
}
|
|
2522
|
+
return [toLocation(definition[0])];
|
|
2523
|
+
});
|
|
2524
|
+
};
|
|
2525
|
+
return DefinitionAdapter;
|
|
2526
|
+
}());
|
|
2527
|
+
exports.DefinitionAdapter = DefinitionAdapter;
|
|
2528
|
+
// --- references ------
|
|
2529
|
+
var ReferenceAdapter = /** @class */ (function () {
|
|
2530
|
+
function ReferenceAdapter(_worker) {
|
|
2531
|
+
this._worker = _worker;
|
|
2532
|
+
}
|
|
2533
|
+
ReferenceAdapter.prototype.provideReferences = function (model, position, context, token) {
|
|
2534
|
+
var resource = model.uri;
|
|
2535
|
+
return this._worker(resource)
|
|
2536
|
+
.then(function (worker) {
|
|
2537
|
+
return worker.findReferences(resource.toString(), fromPosition(position));
|
|
2538
|
+
})
|
|
2539
|
+
.then(function (entries) {
|
|
2540
|
+
if (!entries) {
|
|
2541
|
+
return;
|
|
2542
|
+
}
|
|
2543
|
+
return entries.map(toLocation);
|
|
2544
|
+
});
|
|
2545
|
+
};
|
|
2546
|
+
return ReferenceAdapter;
|
|
2547
|
+
}());
|
|
2548
|
+
exports.ReferenceAdapter = ReferenceAdapter;
|
|
2549
|
+
// --- rename ------
|
|
2550
|
+
function toWorkspaceEdit(edit) {
|
|
2551
|
+
if (!edit || !edit.changes) {
|
|
2552
|
+
return void 0;
|
|
2553
|
+
}
|
|
2554
|
+
var resourceEdits = [];
|
|
2555
|
+
for (var uri in edit.changes) {
|
|
2556
|
+
var _uri = Uri.parse(uri);
|
|
2557
|
+
for (var _i = 0, _a = edit.changes[uri]; _i < _a.length; _i++) {
|
|
2558
|
+
var e = _a[_i];
|
|
2559
|
+
resourceEdits.push({
|
|
2560
|
+
resource: _uri,
|
|
2561
|
+
edit: {
|
|
2562
|
+
range: toRange(e.range),
|
|
2563
|
+
text: e.newText,
|
|
2564
|
+
},
|
|
2565
|
+
});
|
|
2566
|
+
}
|
|
2567
|
+
}
|
|
2568
|
+
return {
|
|
2569
|
+
edits: resourceEdits,
|
|
2570
|
+
};
|
|
2571
|
+
}
|
|
2572
|
+
var RenameAdapter = /** @class */ (function () {
|
|
2573
|
+
function RenameAdapter(_worker) {
|
|
2574
|
+
this._worker = _worker;
|
|
2575
|
+
}
|
|
2576
|
+
RenameAdapter.prototype.provideRenameEdits = function (model, position, newName, token) {
|
|
2577
|
+
var resource = model.uri;
|
|
2578
|
+
return this._worker(resource)
|
|
2579
|
+
.then(function (worker) {
|
|
2580
|
+
return worker.doRename(resource.toString(), fromPosition(position), newName);
|
|
2581
|
+
})
|
|
2582
|
+
.then(function (edit) {
|
|
2583
|
+
return toWorkspaceEdit(edit);
|
|
2584
|
+
});
|
|
2585
|
+
};
|
|
2586
|
+
return RenameAdapter;
|
|
2587
|
+
}());
|
|
2588
|
+
exports.RenameAdapter = RenameAdapter;
|
|
2589
|
+
// --- document symbols ------
|
|
2590
|
+
function toSymbolKind(kind) {
|
|
2591
|
+
var mKind = monaco.languages.SymbolKind;
|
|
2592
|
+
switch (kind) {
|
|
2593
|
+
case ls.SymbolKind.File:
|
|
2594
|
+
return mKind.Array;
|
|
2595
|
+
case ls.SymbolKind.Module:
|
|
2596
|
+
return mKind.Module;
|
|
2597
|
+
case ls.SymbolKind.Namespace:
|
|
2598
|
+
return mKind.Namespace;
|
|
2599
|
+
case ls.SymbolKind.Package:
|
|
2600
|
+
return mKind.Package;
|
|
2601
|
+
case ls.SymbolKind.Class:
|
|
2602
|
+
return mKind.Class;
|
|
2603
|
+
case ls.SymbolKind.Method:
|
|
2604
|
+
return mKind.Method;
|
|
2605
|
+
case ls.SymbolKind.Property:
|
|
2606
|
+
return mKind.Property;
|
|
2607
|
+
case ls.SymbolKind.Field:
|
|
2608
|
+
return mKind.Field;
|
|
2609
|
+
case ls.SymbolKind.Constructor:
|
|
2610
|
+
return mKind.Constructor;
|
|
2611
|
+
case ls.SymbolKind.Enum:
|
|
2612
|
+
return mKind.Enum;
|
|
2613
|
+
case ls.SymbolKind.Interface:
|
|
2614
|
+
return mKind.Interface;
|
|
2615
|
+
case ls.SymbolKind.Function:
|
|
2616
|
+
return mKind.Function;
|
|
2617
|
+
case ls.SymbolKind.Variable:
|
|
2618
|
+
return mKind.Variable;
|
|
2619
|
+
case ls.SymbolKind.Constant:
|
|
2620
|
+
return mKind.Constant;
|
|
2621
|
+
case ls.SymbolKind.String:
|
|
2622
|
+
return mKind.String;
|
|
2623
|
+
case ls.SymbolKind.Number:
|
|
2624
|
+
return mKind.Number;
|
|
2625
|
+
case ls.SymbolKind.Boolean:
|
|
2626
|
+
return mKind.Boolean;
|
|
2627
|
+
case ls.SymbolKind.Array:
|
|
2628
|
+
return mKind.Array;
|
|
2629
|
+
}
|
|
2630
|
+
return mKind.Function;
|
|
2631
|
+
}
|
|
2632
|
+
// --- formatting -----
|
|
2633
|
+
var DocumentFormatAdapter = /** @class */ (function () {
|
|
2634
|
+
function DocumentFormatAdapter(_worker) {
|
|
2635
|
+
this._worker = _worker;
|
|
2636
|
+
}
|
|
2637
|
+
DocumentFormatAdapter.prototype.provideDocumentFormattingEdits = function (model, options, token) {
|
|
2638
|
+
var resource = model.uri;
|
|
2639
|
+
return this._worker(resource).then(function (worker) {
|
|
2640
|
+
return worker.doDocumentFormat(resource.toString()).then(function (edits) { return edits.map(function (edit) { return toTextEdit(edit); }); });
|
|
2641
|
+
});
|
|
2642
|
+
};
|
|
2643
|
+
return DocumentFormatAdapter;
|
|
2644
|
+
}());
|
|
2645
|
+
exports.DocumentFormatAdapter = DocumentFormatAdapter;
|
|
2646
|
+
var FormatAdapter = /** @class */ (function () {
|
|
2647
|
+
function FormatAdapter(_worker) {
|
|
2648
|
+
this._worker = _worker;
|
|
2649
|
+
}
|
|
2650
|
+
FormatAdapter.prototype.provideDocumentRangeFormattingEdits = function (model, range, options, token) {
|
|
2651
|
+
var resource = model.uri;
|
|
2652
|
+
return this._worker(resource).then(function (worker) {
|
|
2653
|
+
return worker
|
|
2654
|
+
.doRangeFormat(resource.toString(), fromRange(range))
|
|
2655
|
+
.then(function (edits) { return edits.map(function (edit) { return toTextEdit(edit); }); });
|
|
2656
|
+
});
|
|
2657
|
+
};
|
|
2658
|
+
return FormatAdapter;
|
|
2659
|
+
}());
|
|
2660
|
+
exports.FormatAdapter = FormatAdapter;
|
|
2661
|
+
// --- Folding ---
|
|
2662
|
+
var FoldingAdapter = /** @class */ (function () {
|
|
2663
|
+
function FoldingAdapter(_worker) {
|
|
2664
|
+
this._worker = _worker;
|
|
2665
|
+
}
|
|
2666
|
+
FoldingAdapter.prototype.provideFoldingRanges = function (model, context, token) {
|
|
2667
|
+
var resource = model.uri;
|
|
2668
|
+
return this._worker(resource).then(function (worker) {
|
|
2669
|
+
return worker
|
|
2670
|
+
.doFolding(resource.toString())
|
|
2671
|
+
.then(function (foldingRanges) {
|
|
2672
|
+
return foldingRanges.map(function (range) { return toFoldingRange(range); });
|
|
2673
|
+
});
|
|
2674
|
+
});
|
|
2675
|
+
};
|
|
2676
|
+
return FoldingAdapter;
|
|
2677
|
+
}());
|
|
2678
|
+
exports.FoldingAdapter = FoldingAdapter;
|
|
2679
|
+
function toFoldingRange(range) {
|
|
2680
|
+
return {
|
|
2681
|
+
start: range.startLine + 1,
|
|
2682
|
+
end: range.endLine + 1,
|
|
2683
|
+
kind: monaco.languages.FoldingRangeKind.Region,
|
|
2684
|
+
};
|
|
2685
|
+
}
|
|
2686
|
+
// --- hover ------
|
|
2687
|
+
var HoverAdapter = /** @class */ (function () {
|
|
2688
|
+
function HoverAdapter(_worker) {
|
|
2689
|
+
this._worker = _worker;
|
|
2690
|
+
}
|
|
2691
|
+
HoverAdapter.prototype.provideHover = function (model, position, token) {
|
|
2692
|
+
var resource = model.uri;
|
|
2693
|
+
return this._worker(resource)
|
|
2694
|
+
.then(function (worker) {
|
|
2695
|
+
return worker.doHover(resource.toString(), fromPosition(position));
|
|
2696
|
+
})
|
|
2697
|
+
.then(function (info) {
|
|
2698
|
+
if (!info) {
|
|
2699
|
+
return;
|
|
2700
|
+
}
|
|
2701
|
+
return {
|
|
2702
|
+
range: toRange(info.range),
|
|
2703
|
+
contents: toMarkedStringArray(info.contents),
|
|
2704
|
+
};
|
|
2705
|
+
});
|
|
2706
|
+
};
|
|
2707
|
+
return HoverAdapter;
|
|
2708
|
+
}());
|
|
2709
|
+
exports.HoverAdapter = HoverAdapter;
|
|
2710
|
+
});
|
|
2711
2711
|
|
|
2712
|
-
var __assign = (this && this.__assign) || function () {
|
|
2713
|
-
__assign = Object.assign || function(t) {
|
|
2714
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
2715
|
-
s = arguments[i];
|
|
2716
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
2717
|
-
t[p] = s[p];
|
|
2718
|
-
}
|
|
2719
|
-
return t;
|
|
2720
|
-
};
|
|
2721
|
-
return __assign.apply(this, arguments);
|
|
2722
|
-
};
|
|
2723
|
-
define('vs/language/kusto/kustoMode',["require", "exports", "./workerManager", "./languageService/kustoMonarchLanguageDefinition", "./languageFeatures"], function (require, exports, workerManager_1, kustoMonarchLanguageDefinition_1, languageFeatures) {
|
|
2724
|
-
"use strict";
|
|
2725
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2726
|
-
exports.getKustoWorker = exports.setupMode = void 0;
|
|
2727
|
-
var kustoWorker;
|
|
2728
|
-
var resolveWorker;
|
|
2729
|
-
var rejectWorker;
|
|
2730
|
-
var workerPromise = new Promise(function (resolve, reject) {
|
|
2731
|
-
resolveWorker = resolve;
|
|
2732
|
-
rejectWorker = reject;
|
|
2733
|
-
});
|
|
2734
|
-
/**
|
|
2735
|
-
* Called when Kusto language is first needed (a model has the language set)
|
|
2736
|
-
* @param defaults
|
|
2737
|
-
*/
|
|
2738
|
-
function setupMode(defaults, monacoInstance) {
|
|
2739
|
-
var onSchemaChange = new monaco.Emitter();
|
|
2740
|
-
// TODO: when should we dispose of these? seems like monaco-css and monaco-typescript don't dispose of these.
|
|
2741
|
-
var disposables = [];
|
|
2742
|
-
var monarchTokensProvider;
|
|
2743
|
-
var client = new workerManager_1.WorkerManager(monacoInstance, defaults);
|
|
2744
|
-
disposables.push(client);
|
|
2745
|
-
var workerAccessor = function (first) {
|
|
2746
|
-
var more = [];
|
|
2747
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2748
|
-
more[_i - 1] = arguments[_i];
|
|
2749
|
-
}
|
|
2750
|
-
var augmentedSetSchema = function (schema, worker, globalParameters) {
|
|
2751
|
-
var workerPromise = worker.setSchema(schema);
|
|
2752
|
-
workerPromise.then(function () {
|
|
2753
|
-
onSchemaChange.fire(schema);
|
|
2754
|
-
});
|
|
2755
|
-
};
|
|
2756
|
-
var worker = client.getLanguageServiceWorker.apply(client, [first].concat(more));
|
|
2757
|
-
return worker.then(function (worker) {
|
|
2758
|
-
return (__assign(__assign({}, worker), { setSchema: function (schema) { return augmentedSetSchema(schema, worker); }, setSchemaFromShowSchema: function (schema, connection, database, globalParameters) {
|
|
2759
|
-
worker
|
|
2760
|
-
.normalizeSchema(schema, connection, database)
|
|
2761
|
-
.then(function (schema) { return (globalParameters ? __assign(__assign({}, schema), { globalParameters: globalParameters }) : schema); })
|
|
2762
|
-
.then(function (normalized) { return augmentedSetSchema(normalized, worker); });
|
|
2763
|
-
} }));
|
|
2764
|
-
});
|
|
2765
|
-
};
|
|
2766
|
-
var language = 'kusto';
|
|
2767
|
-
disposables.push(monacoInstance.languages.registerCompletionItemProvider(language, new languageFeatures.CompletionAdapter(workerAccessor, defaults.languageSettings)));
|
|
2768
|
-
// Monaco tokenization runs in main thread so we're using a quick schema-unaware tokenization.
|
|
2769
|
-
// a web worker will run semantic colorization in the background (ColorizationAdapter).
|
|
2770
|
-
if (defaults.languageSettings.useTokenColorization) {
|
|
2771
|
-
monarchTokensProvider = monacoInstance.languages.setMonarchTokensProvider(language, kustoMonarchLanguageDefinition_1.KustoLanguageDefinition);
|
|
2772
|
-
}
|
|
2773
|
-
// listen to configuration changes and if we're switching from semantic to monarch colorization, do the switch.
|
|
2774
|
-
defaults.onDidChange(function (e) {
|
|
2775
|
-
if (!e.languageSettings.useTokenColorization && monarchTokensProvider !== undefined) {
|
|
2776
|
-
monarchTokensProvider.dispose();
|
|
2777
|
-
monarchTokensProvider = undefined;
|
|
2778
|
-
}
|
|
2779
|
-
if (e.languageSettings.useTokenColorization && monarchTokensProvider == undefined) {
|
|
2780
|
-
monarchTokensProvider = monacoInstance.languages.setMonarchTokensProvider(language, kustoMonarchLanguageDefinition_1.KustoLanguageDefinition);
|
|
2781
|
-
}
|
|
2782
|
-
});
|
|
2783
|
-
disposables.push(new languageFeatures.DiagnosticsAdapter(monacoInstance, language, workerAccessor, defaults, onSchemaChange.event));
|
|
2784
|
-
disposables.push(new languageFeatures.ColorizationAdapter(monacoInstance, language, workerAccessor, defaults, onSchemaChange.event));
|
|
2785
|
-
disposables.push(monacoInstance.languages.registerDocumentRangeFormattingEditProvider(language, new languageFeatures.FormatAdapter(workerAccessor)));
|
|
2786
|
-
disposables.push(monacoInstance.languages.registerFoldingRangeProvider(language, new languageFeatures.FoldingAdapter(workerAccessor)));
|
|
2787
|
-
disposables.push(monacoInstance.languages.registerDefinitionProvider(language, new languageFeatures.DefinitionAdapter(workerAccessor)));
|
|
2788
|
-
disposables.push(monacoInstance.languages.registerRenameProvider(language, new languageFeatures.RenameAdapter(workerAccessor)));
|
|
2789
|
-
disposables.push(monacoInstance.languages.registerReferenceProvider(language, new languageFeatures.ReferenceAdapter(workerAccessor)));
|
|
2790
|
-
if (defaults.languageSettings.enableHover) {
|
|
2791
|
-
disposables.push(monacoInstance.languages.registerHoverProvider(language, new languageFeatures.HoverAdapter(workerAccessor)));
|
|
2792
|
-
}
|
|
2793
|
-
monacoInstance.languages.registerDocumentFormattingEditProvider(language, new languageFeatures.DocumentFormatAdapter(workerAccessor));
|
|
2794
|
-
kustoWorker = workerAccessor;
|
|
2795
|
-
resolveWorker(workerAccessor);
|
|
2796
|
-
monacoInstance.languages.setLanguageConfiguration(language, {
|
|
2797
|
-
folding: {
|
|
2798
|
-
offSide: false,
|
|
2799
|
-
markers: { start: /^\s*[\r\n]/gm, end: /^\s*[\r\n]/gm },
|
|
2800
|
-
},
|
|
2801
|
-
comments: {
|
|
2802
|
-
lineComment: '//',
|
|
2803
|
-
blockComment: null,
|
|
2804
|
-
},
|
|
2805
|
-
});
|
|
2806
|
-
return kustoWorker;
|
|
2807
|
-
}
|
|
2808
|
-
exports.setupMode = setupMode;
|
|
2809
|
-
function getKustoWorker() {
|
|
2810
|
-
return workerPromise.then(function () { return kustoWorker; });
|
|
2811
|
-
}
|
|
2812
|
-
exports.getKustoWorker = getKustoWorker;
|
|
2813
|
-
});
|
|
2712
|
+
var __assign = (this && this.__assign) || function () {
|
|
2713
|
+
__assign = Object.assign || function(t) {
|
|
2714
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
2715
|
+
s = arguments[i];
|
|
2716
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
2717
|
+
t[p] = s[p];
|
|
2718
|
+
}
|
|
2719
|
+
return t;
|
|
2720
|
+
};
|
|
2721
|
+
return __assign.apply(this, arguments);
|
|
2722
|
+
};
|
|
2723
|
+
define('vs/language/kusto/kustoMode',["require", "exports", "./workerManager", "./languageService/kustoMonarchLanguageDefinition", "./languageFeatures"], function (require, exports, workerManager_1, kustoMonarchLanguageDefinition_1, languageFeatures) {
|
|
2724
|
+
"use strict";
|
|
2725
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2726
|
+
exports.getKustoWorker = exports.setupMode = void 0;
|
|
2727
|
+
var kustoWorker;
|
|
2728
|
+
var resolveWorker;
|
|
2729
|
+
var rejectWorker;
|
|
2730
|
+
var workerPromise = new Promise(function (resolve, reject) {
|
|
2731
|
+
resolveWorker = resolve;
|
|
2732
|
+
rejectWorker = reject;
|
|
2733
|
+
});
|
|
2734
|
+
/**
|
|
2735
|
+
* Called when Kusto language is first needed (a model has the language set)
|
|
2736
|
+
* @param defaults
|
|
2737
|
+
*/
|
|
2738
|
+
function setupMode(defaults, monacoInstance) {
|
|
2739
|
+
var onSchemaChange = new monaco.Emitter();
|
|
2740
|
+
// TODO: when should we dispose of these? seems like monaco-css and monaco-typescript don't dispose of these.
|
|
2741
|
+
var disposables = [];
|
|
2742
|
+
var monarchTokensProvider;
|
|
2743
|
+
var client = new workerManager_1.WorkerManager(monacoInstance, defaults);
|
|
2744
|
+
disposables.push(client);
|
|
2745
|
+
var workerAccessor = function (first) {
|
|
2746
|
+
var more = [];
|
|
2747
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2748
|
+
more[_i - 1] = arguments[_i];
|
|
2749
|
+
}
|
|
2750
|
+
var augmentedSetSchema = function (schema, worker, globalParameters) {
|
|
2751
|
+
var workerPromise = worker.setSchema(schema);
|
|
2752
|
+
workerPromise.then(function () {
|
|
2753
|
+
onSchemaChange.fire(schema);
|
|
2754
|
+
});
|
|
2755
|
+
};
|
|
2756
|
+
var worker = client.getLanguageServiceWorker.apply(client, [first].concat(more));
|
|
2757
|
+
return worker.then(function (worker) {
|
|
2758
|
+
return (__assign(__assign({}, worker), { setSchema: function (schema) { return augmentedSetSchema(schema, worker); }, setSchemaFromShowSchema: function (schema, connection, database, globalParameters) {
|
|
2759
|
+
worker
|
|
2760
|
+
.normalizeSchema(schema, connection, database)
|
|
2761
|
+
.then(function (schema) { return (globalParameters ? __assign(__assign({}, schema), { globalParameters: globalParameters }) : schema); })
|
|
2762
|
+
.then(function (normalized) { return augmentedSetSchema(normalized, worker); });
|
|
2763
|
+
} }));
|
|
2764
|
+
});
|
|
2765
|
+
};
|
|
2766
|
+
var language = 'kusto';
|
|
2767
|
+
disposables.push(monacoInstance.languages.registerCompletionItemProvider(language, new languageFeatures.CompletionAdapter(workerAccessor, defaults.languageSettings)));
|
|
2768
|
+
// Monaco tokenization runs in main thread so we're using a quick schema-unaware tokenization.
|
|
2769
|
+
// a web worker will run semantic colorization in the background (ColorizationAdapter).
|
|
2770
|
+
if (defaults.languageSettings.useTokenColorization) {
|
|
2771
|
+
monarchTokensProvider = monacoInstance.languages.setMonarchTokensProvider(language, kustoMonarchLanguageDefinition_1.KustoLanguageDefinition);
|
|
2772
|
+
}
|
|
2773
|
+
// listen to configuration changes and if we're switching from semantic to monarch colorization, do the switch.
|
|
2774
|
+
defaults.onDidChange(function (e) {
|
|
2775
|
+
if (!e.languageSettings.useTokenColorization && monarchTokensProvider !== undefined) {
|
|
2776
|
+
monarchTokensProvider.dispose();
|
|
2777
|
+
monarchTokensProvider = undefined;
|
|
2778
|
+
}
|
|
2779
|
+
if (e.languageSettings.useTokenColorization && monarchTokensProvider == undefined) {
|
|
2780
|
+
monarchTokensProvider = monacoInstance.languages.setMonarchTokensProvider(language, kustoMonarchLanguageDefinition_1.KustoLanguageDefinition);
|
|
2781
|
+
}
|
|
2782
|
+
});
|
|
2783
|
+
disposables.push(new languageFeatures.DiagnosticsAdapter(monacoInstance, language, workerAccessor, defaults, onSchemaChange.event));
|
|
2784
|
+
disposables.push(new languageFeatures.ColorizationAdapter(monacoInstance, language, workerAccessor, defaults, onSchemaChange.event));
|
|
2785
|
+
disposables.push(monacoInstance.languages.registerDocumentRangeFormattingEditProvider(language, new languageFeatures.FormatAdapter(workerAccessor)));
|
|
2786
|
+
disposables.push(monacoInstance.languages.registerFoldingRangeProvider(language, new languageFeatures.FoldingAdapter(workerAccessor)));
|
|
2787
|
+
disposables.push(monacoInstance.languages.registerDefinitionProvider(language, new languageFeatures.DefinitionAdapter(workerAccessor)));
|
|
2788
|
+
disposables.push(monacoInstance.languages.registerRenameProvider(language, new languageFeatures.RenameAdapter(workerAccessor)));
|
|
2789
|
+
disposables.push(monacoInstance.languages.registerReferenceProvider(language, new languageFeatures.ReferenceAdapter(workerAccessor)));
|
|
2790
|
+
if (defaults.languageSettings.enableHover) {
|
|
2791
|
+
disposables.push(monacoInstance.languages.registerHoverProvider(language, new languageFeatures.HoverAdapter(workerAccessor)));
|
|
2792
|
+
}
|
|
2793
|
+
monacoInstance.languages.registerDocumentFormattingEditProvider(language, new languageFeatures.DocumentFormatAdapter(workerAccessor));
|
|
2794
|
+
kustoWorker = workerAccessor;
|
|
2795
|
+
resolveWorker(workerAccessor);
|
|
2796
|
+
monacoInstance.languages.setLanguageConfiguration(language, {
|
|
2797
|
+
folding: {
|
|
2798
|
+
offSide: false,
|
|
2799
|
+
markers: { start: /^\s*[\r\n]/gm, end: /^\s*[\r\n]/gm },
|
|
2800
|
+
},
|
|
2801
|
+
comments: {
|
|
2802
|
+
lineComment: '//',
|
|
2803
|
+
blockComment: null,
|
|
2804
|
+
},
|
|
2805
|
+
});
|
|
2806
|
+
return kustoWorker;
|
|
2807
|
+
}
|
|
2808
|
+
exports.setupMode = setupMode;
|
|
2809
|
+
function getKustoWorker() {
|
|
2810
|
+
return workerPromise.then(function () { return kustoWorker; });
|
|
2811
|
+
}
|
|
2812
|
+
exports.getKustoWorker = getKustoWorker;
|
|
2813
|
+
});
|
|
2814
2814
|
|