@kusto/monaco-kusto 3.2.4 → 3.2.7

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