@arcgis/coding-components 4.29.0-beta.74 → 4.29.0-beta.76

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,2038 +0,0 @@
1
- 'use strict';
2
-
3
- const arcadeDefaults = require('./arcade-defaults-298b308e.js');
4
- require('./index-ac186201.js');
5
-
6
- /*!-----------------------------------------------------------------------------
7
- * Copyright (c) Microsoft Corporation. All rights reserved.
8
- * Version: 0.45.0(5e5af013f8d295555a7210df0d5f2cea0bf5dd56)
9
- * Released under the MIT license
10
- * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
11
- *-----------------------------------------------------------------------------*/
12
-
13
- var __defProp = Object.defineProperty;
14
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
15
- var __getOwnPropNames = Object.getOwnPropertyNames;
16
- var __hasOwnProp = Object.prototype.hasOwnProperty;
17
- var __copyProps = (to, from, except, desc) => {
18
- if (from && typeof from === "object" || typeof from === "function") {
19
- for (let key of __getOwnPropNames(from))
20
- if (!__hasOwnProp.call(to, key) && key !== except)
21
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22
- }
23
- return to;
24
- };
25
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
26
-
27
- // src/fillers/monaco-editor-core.ts
28
- var monaco_editor_core_exports = {};
29
- __reExport(monaco_editor_core_exports, arcadeDefaults.monaco_editor_core_star);
30
-
31
- // src/language/css/workerManager.ts
32
- var STOP_WHEN_IDLE_FOR = 2 * 60 * 1e3;
33
- var WorkerManager = class {
34
- _defaults;
35
- _idleCheckInterval;
36
- _lastUsedTime;
37
- _configChangeListener;
38
- _worker;
39
- _client;
40
- constructor(defaults) {
41
- this._defaults = defaults;
42
- this._worker = null;
43
- this._client = null;
44
- this._idleCheckInterval = window.setInterval(() => this._checkIfIdle(), 30 * 1e3);
45
- this._lastUsedTime = 0;
46
- this._configChangeListener = this._defaults.onDidChange(() => this._stopWorker());
47
- }
48
- _stopWorker() {
49
- if (this._worker) {
50
- this._worker.dispose();
51
- this._worker = null;
52
- }
53
- this._client = null;
54
- }
55
- dispose() {
56
- clearInterval(this._idleCheckInterval);
57
- this._configChangeListener.dispose();
58
- this._stopWorker();
59
- }
60
- _checkIfIdle() {
61
- if (!this._worker) {
62
- return;
63
- }
64
- let timePassedSinceLastUsed = Date.now() - this._lastUsedTime;
65
- if (timePassedSinceLastUsed > STOP_WHEN_IDLE_FOR) {
66
- this._stopWorker();
67
- }
68
- }
69
- _getClient() {
70
- this._lastUsedTime = Date.now();
71
- if (!this._client) {
72
- this._worker = monaco_editor_core_exports.editor.createWebWorker({
73
- moduleId: "vs/language/css/cssWorker",
74
- label: this._defaults.languageId,
75
- createData: {
76
- options: this._defaults.options,
77
- languageId: this._defaults.languageId
78
- }
79
- });
80
- this._client = this._worker.getProxy();
81
- }
82
- return this._client;
83
- }
84
- getLanguageServiceWorker(...resources) {
85
- let _client;
86
- return this._getClient().then((client) => {
87
- _client = client;
88
- }).then((_) => {
89
- if (this._worker) {
90
- return this._worker.withSyncedResources(resources);
91
- }
92
- }).then((_) => _client);
93
- }
94
- };
95
-
96
- // node_modules/vscode-languageserver-types/lib/esm/main.js
97
- var integer;
98
- (function(integer2) {
99
- integer2.MIN_VALUE = -2147483648;
100
- integer2.MAX_VALUE = 2147483647;
101
- })(integer || (integer = {}));
102
- var uinteger;
103
- (function(uinteger2) {
104
- uinteger2.MIN_VALUE = 0;
105
- uinteger2.MAX_VALUE = 2147483647;
106
- })(uinteger || (uinteger = {}));
107
- var Position;
108
- (function(Position3) {
109
- function create(line, character) {
110
- if (line === Number.MAX_VALUE) {
111
- line = uinteger.MAX_VALUE;
112
- }
113
- if (character === Number.MAX_VALUE) {
114
- character = uinteger.MAX_VALUE;
115
- }
116
- return { line, character };
117
- }
118
- Position3.create = create;
119
- function is(value) {
120
- var candidate = value;
121
- return Is.objectLiteral(candidate) && Is.uinteger(candidate.line) && Is.uinteger(candidate.character);
122
- }
123
- Position3.is = is;
124
- })(Position || (Position = {}));
125
- var Range;
126
- (function(Range3) {
127
- function create(one, two, three, four) {
128
- if (Is.uinteger(one) && Is.uinteger(two) && Is.uinteger(three) && Is.uinteger(four)) {
129
- return { start: Position.create(one, two), end: Position.create(three, four) };
130
- } else if (Position.is(one) && Position.is(two)) {
131
- return { start: one, end: two };
132
- } else {
133
- throw new Error("Range#create called with invalid arguments[" + one + ", " + two + ", " + three + ", " + four + "]");
134
- }
135
- }
136
- Range3.create = create;
137
- function is(value) {
138
- var candidate = value;
139
- return Is.objectLiteral(candidate) && Position.is(candidate.start) && Position.is(candidate.end);
140
- }
141
- Range3.is = is;
142
- })(Range || (Range = {}));
143
- var Location;
144
- (function(Location2) {
145
- function create(uri, range) {
146
- return { uri, range };
147
- }
148
- Location2.create = create;
149
- function is(value) {
150
- var candidate = value;
151
- return Is.defined(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
152
- }
153
- Location2.is = is;
154
- })(Location || (Location = {}));
155
- var LocationLink;
156
- (function(LocationLink2) {
157
- function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) {
158
- return { targetUri, targetRange, targetSelectionRange, originSelectionRange };
159
- }
160
- LocationLink2.create = create;
161
- function is(value) {
162
- var candidate = value;
163
- return Is.defined(candidate) && Range.is(candidate.targetRange) && Is.string(candidate.targetUri) && (Range.is(candidate.targetSelectionRange) || Is.undefined(candidate.targetSelectionRange)) && (Range.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));
164
- }
165
- LocationLink2.is = is;
166
- })(LocationLink || (LocationLink = {}));
167
- var Color;
168
- (function(Color2) {
169
- function create(red, green, blue, alpha) {
170
- return {
171
- red,
172
- green,
173
- blue,
174
- alpha
175
- };
176
- }
177
- Color2.create = create;
178
- function is(value) {
179
- var candidate = value;
180
- return Is.numberRange(candidate.red, 0, 1) && Is.numberRange(candidate.green, 0, 1) && Is.numberRange(candidate.blue, 0, 1) && Is.numberRange(candidate.alpha, 0, 1);
181
- }
182
- Color2.is = is;
183
- })(Color || (Color = {}));
184
- var ColorInformation;
185
- (function(ColorInformation2) {
186
- function create(range, color) {
187
- return {
188
- range,
189
- color
190
- };
191
- }
192
- ColorInformation2.create = create;
193
- function is(value) {
194
- var candidate = value;
195
- return Range.is(candidate.range) && Color.is(candidate.color);
196
- }
197
- ColorInformation2.is = is;
198
- })(ColorInformation || (ColorInformation = {}));
199
- var ColorPresentation;
200
- (function(ColorPresentation2) {
201
- function create(label, textEdit, additionalTextEdits) {
202
- return {
203
- label,
204
- textEdit,
205
- additionalTextEdits
206
- };
207
- }
208
- ColorPresentation2.create = create;
209
- function is(value) {
210
- var candidate = value;
211
- return Is.string(candidate.label) && (Is.undefined(candidate.textEdit) || TextEdit.is(candidate)) && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit.is));
212
- }
213
- ColorPresentation2.is = is;
214
- })(ColorPresentation || (ColorPresentation = {}));
215
- var FoldingRangeKind;
216
- (function(FoldingRangeKind2) {
217
- FoldingRangeKind2["Comment"] = "comment";
218
- FoldingRangeKind2["Imports"] = "imports";
219
- FoldingRangeKind2["Region"] = "region";
220
- })(FoldingRangeKind || (FoldingRangeKind = {}));
221
- var FoldingRange;
222
- (function(FoldingRange2) {
223
- function create(startLine, endLine, startCharacter, endCharacter, kind) {
224
- var result = {
225
- startLine,
226
- endLine
227
- };
228
- if (Is.defined(startCharacter)) {
229
- result.startCharacter = startCharacter;
230
- }
231
- if (Is.defined(endCharacter)) {
232
- result.endCharacter = endCharacter;
233
- }
234
- if (Is.defined(kind)) {
235
- result.kind = kind;
236
- }
237
- return result;
238
- }
239
- FoldingRange2.create = create;
240
- function is(value) {
241
- var candidate = value;
242
- return Is.uinteger(candidate.startLine) && Is.uinteger(candidate.startLine) && (Is.undefined(candidate.startCharacter) || Is.uinteger(candidate.startCharacter)) && (Is.undefined(candidate.endCharacter) || Is.uinteger(candidate.endCharacter)) && (Is.undefined(candidate.kind) || Is.string(candidate.kind));
243
- }
244
- FoldingRange2.is = is;
245
- })(FoldingRange || (FoldingRange = {}));
246
- var DiagnosticRelatedInformation;
247
- (function(DiagnosticRelatedInformation2) {
248
- function create(location, message) {
249
- return {
250
- location,
251
- message
252
- };
253
- }
254
- DiagnosticRelatedInformation2.create = create;
255
- function is(value) {
256
- var candidate = value;
257
- return Is.defined(candidate) && Location.is(candidate.location) && Is.string(candidate.message);
258
- }
259
- DiagnosticRelatedInformation2.is = is;
260
- })(DiagnosticRelatedInformation || (DiagnosticRelatedInformation = {}));
261
- var DiagnosticSeverity;
262
- (function(DiagnosticSeverity2) {
263
- DiagnosticSeverity2.Error = 1;
264
- DiagnosticSeverity2.Warning = 2;
265
- DiagnosticSeverity2.Information = 3;
266
- DiagnosticSeverity2.Hint = 4;
267
- })(DiagnosticSeverity || (DiagnosticSeverity = {}));
268
- var DiagnosticTag;
269
- (function(DiagnosticTag2) {
270
- DiagnosticTag2.Unnecessary = 1;
271
- DiagnosticTag2.Deprecated = 2;
272
- })(DiagnosticTag || (DiagnosticTag = {}));
273
- var CodeDescription;
274
- (function(CodeDescription2) {
275
- function is(value) {
276
- var candidate = value;
277
- return candidate !== void 0 && candidate !== null && Is.string(candidate.href);
278
- }
279
- CodeDescription2.is = is;
280
- })(CodeDescription || (CodeDescription = {}));
281
- var Diagnostic;
282
- (function(Diagnostic2) {
283
- function create(range, message, severity, code, source, relatedInformation) {
284
- var result = { range, message };
285
- if (Is.defined(severity)) {
286
- result.severity = severity;
287
- }
288
- if (Is.defined(code)) {
289
- result.code = code;
290
- }
291
- if (Is.defined(source)) {
292
- result.source = source;
293
- }
294
- if (Is.defined(relatedInformation)) {
295
- result.relatedInformation = relatedInformation;
296
- }
297
- return result;
298
- }
299
- Diagnostic2.create = create;
300
- function is(value) {
301
- var _a;
302
- var candidate = value;
303
- return Is.defined(candidate) && Range.is(candidate.range) && Is.string(candidate.message) && (Is.number(candidate.severity) || Is.undefined(candidate.severity)) && (Is.integer(candidate.code) || Is.string(candidate.code) || Is.undefined(candidate.code)) && (Is.undefined(candidate.codeDescription) || Is.string((_a = candidate.codeDescription) === null || _a === void 0 ? void 0 : _a.href)) && (Is.string(candidate.source) || Is.undefined(candidate.source)) && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is));
304
- }
305
- Diagnostic2.is = is;
306
- })(Diagnostic || (Diagnostic = {}));
307
- var Command;
308
- (function(Command2) {
309
- function create(title, command) {
310
- var args = [];
311
- for (var _i = 2; _i < arguments.length; _i++) {
312
- args[_i - 2] = arguments[_i];
313
- }
314
- var result = { title, command };
315
- if (Is.defined(args) && args.length > 0) {
316
- result.arguments = args;
317
- }
318
- return result;
319
- }
320
- Command2.create = create;
321
- function is(value) {
322
- var candidate = value;
323
- return Is.defined(candidate) && Is.string(candidate.title) && Is.string(candidate.command);
324
- }
325
- Command2.is = is;
326
- })(Command || (Command = {}));
327
- var TextEdit;
328
- (function(TextEdit2) {
329
- function replace(range, newText) {
330
- return { range, newText };
331
- }
332
- TextEdit2.replace = replace;
333
- function insert(position, newText) {
334
- return { range: { start: position, end: position }, newText };
335
- }
336
- TextEdit2.insert = insert;
337
- function del(range) {
338
- return { range, newText: "" };
339
- }
340
- TextEdit2.del = del;
341
- function is(value) {
342
- var candidate = value;
343
- return Is.objectLiteral(candidate) && Is.string(candidate.newText) && Range.is(candidate.range);
344
- }
345
- TextEdit2.is = is;
346
- })(TextEdit || (TextEdit = {}));
347
- var ChangeAnnotation;
348
- (function(ChangeAnnotation2) {
349
- function create(label, needsConfirmation, description) {
350
- var result = { label };
351
- if (needsConfirmation !== void 0) {
352
- result.needsConfirmation = needsConfirmation;
353
- }
354
- if (description !== void 0) {
355
- result.description = description;
356
- }
357
- return result;
358
- }
359
- ChangeAnnotation2.create = create;
360
- function is(value) {
361
- var candidate = value;
362
- return candidate !== void 0 && Is.objectLiteral(candidate) && Is.string(candidate.label) && (Is.boolean(candidate.needsConfirmation) || candidate.needsConfirmation === void 0) && (Is.string(candidate.description) || candidate.description === void 0);
363
- }
364
- ChangeAnnotation2.is = is;
365
- })(ChangeAnnotation || (ChangeAnnotation = {}));
366
- var ChangeAnnotationIdentifier;
367
- (function(ChangeAnnotationIdentifier2) {
368
- function is(value) {
369
- var candidate = value;
370
- return typeof candidate === "string";
371
- }
372
- ChangeAnnotationIdentifier2.is = is;
373
- })(ChangeAnnotationIdentifier || (ChangeAnnotationIdentifier = {}));
374
- var AnnotatedTextEdit;
375
- (function(AnnotatedTextEdit2) {
376
- function replace(range, newText, annotation) {
377
- return { range, newText, annotationId: annotation };
378
- }
379
- AnnotatedTextEdit2.replace = replace;
380
- function insert(position, newText, annotation) {
381
- return { range: { start: position, end: position }, newText, annotationId: annotation };
382
- }
383
- AnnotatedTextEdit2.insert = insert;
384
- function del(range, annotation) {
385
- return { range, newText: "", annotationId: annotation };
386
- }
387
- AnnotatedTextEdit2.del = del;
388
- function is(value) {
389
- var candidate = value;
390
- return TextEdit.is(candidate) && (ChangeAnnotation.is(candidate.annotationId) || ChangeAnnotationIdentifier.is(candidate.annotationId));
391
- }
392
- AnnotatedTextEdit2.is = is;
393
- })(AnnotatedTextEdit || (AnnotatedTextEdit = {}));
394
- var TextDocumentEdit;
395
- (function(TextDocumentEdit2) {
396
- function create(textDocument, edits) {
397
- return { textDocument, edits };
398
- }
399
- TextDocumentEdit2.create = create;
400
- function is(value) {
401
- var candidate = value;
402
- return Is.defined(candidate) && OptionalVersionedTextDocumentIdentifier.is(candidate.textDocument) && Array.isArray(candidate.edits);
403
- }
404
- TextDocumentEdit2.is = is;
405
- })(TextDocumentEdit || (TextDocumentEdit = {}));
406
- var CreateFile;
407
- (function(CreateFile2) {
408
- function create(uri, options, annotation) {
409
- var result = {
410
- kind: "create",
411
- uri
412
- };
413
- if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
414
- result.options = options;
415
- }
416
- if (annotation !== void 0) {
417
- result.annotationId = annotation;
418
- }
419
- return result;
420
- }
421
- CreateFile2.create = create;
422
- function is(value) {
423
- var candidate = value;
424
- return candidate && candidate.kind === "create" && Is.string(candidate.uri) && (candidate.options === void 0 || (candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))) && (candidate.annotationId === void 0 || ChangeAnnotationIdentifier.is(candidate.annotationId));
425
- }
426
- CreateFile2.is = is;
427
- })(CreateFile || (CreateFile = {}));
428
- var RenameFile;
429
- (function(RenameFile2) {
430
- function create(oldUri, newUri, options, annotation) {
431
- var result = {
432
- kind: "rename",
433
- oldUri,
434
- newUri
435
- };
436
- if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
437
- result.options = options;
438
- }
439
- if (annotation !== void 0) {
440
- result.annotationId = annotation;
441
- }
442
- return result;
443
- }
444
- RenameFile2.create = create;
445
- function is(value) {
446
- var candidate = value;
447
- return candidate && candidate.kind === "rename" && Is.string(candidate.oldUri) && Is.string(candidate.newUri) && (candidate.options === void 0 || (candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))) && (candidate.annotationId === void 0 || ChangeAnnotationIdentifier.is(candidate.annotationId));
448
- }
449
- RenameFile2.is = is;
450
- })(RenameFile || (RenameFile = {}));
451
- var DeleteFile;
452
- (function(DeleteFile2) {
453
- function create(uri, options, annotation) {
454
- var result = {
455
- kind: "delete",
456
- uri
457
- };
458
- if (options !== void 0 && (options.recursive !== void 0 || options.ignoreIfNotExists !== void 0)) {
459
- result.options = options;
460
- }
461
- if (annotation !== void 0) {
462
- result.annotationId = annotation;
463
- }
464
- return result;
465
- }
466
- DeleteFile2.create = create;
467
- function is(value) {
468
- var candidate = value;
469
- return candidate && candidate.kind === "delete" && Is.string(candidate.uri) && (candidate.options === void 0 || (candidate.options.recursive === void 0 || Is.boolean(candidate.options.recursive)) && (candidate.options.ignoreIfNotExists === void 0 || Is.boolean(candidate.options.ignoreIfNotExists))) && (candidate.annotationId === void 0 || ChangeAnnotationIdentifier.is(candidate.annotationId));
470
- }
471
- DeleteFile2.is = is;
472
- })(DeleteFile || (DeleteFile = {}));
473
- var WorkspaceEdit;
474
- (function(WorkspaceEdit2) {
475
- function is(value) {
476
- var candidate = value;
477
- return candidate && (candidate.changes !== void 0 || candidate.documentChanges !== void 0) && (candidate.documentChanges === void 0 || candidate.documentChanges.every(function(change) {
478
- if (Is.string(change.kind)) {
479
- return CreateFile.is(change) || RenameFile.is(change) || DeleteFile.is(change);
480
- } else {
481
- return TextDocumentEdit.is(change);
482
- }
483
- }));
484
- }
485
- WorkspaceEdit2.is = is;
486
- })(WorkspaceEdit || (WorkspaceEdit = {}));
487
- var TextEditChangeImpl = function() {
488
- function TextEditChangeImpl2(edits, changeAnnotations) {
489
- this.edits = edits;
490
- this.changeAnnotations = changeAnnotations;
491
- }
492
- TextEditChangeImpl2.prototype.insert = function(position, newText, annotation) {
493
- var edit;
494
- var id;
495
- if (annotation === void 0) {
496
- edit = TextEdit.insert(position, newText);
497
- } else if (ChangeAnnotationIdentifier.is(annotation)) {
498
- id = annotation;
499
- edit = AnnotatedTextEdit.insert(position, newText, annotation);
500
- } else {
501
- this.assertChangeAnnotations(this.changeAnnotations);
502
- id = this.changeAnnotations.manage(annotation);
503
- edit = AnnotatedTextEdit.insert(position, newText, id);
504
- }
505
- this.edits.push(edit);
506
- if (id !== void 0) {
507
- return id;
508
- }
509
- };
510
- TextEditChangeImpl2.prototype.replace = function(range, newText, annotation) {
511
- var edit;
512
- var id;
513
- if (annotation === void 0) {
514
- edit = TextEdit.replace(range, newText);
515
- } else if (ChangeAnnotationIdentifier.is(annotation)) {
516
- id = annotation;
517
- edit = AnnotatedTextEdit.replace(range, newText, annotation);
518
- } else {
519
- this.assertChangeAnnotations(this.changeAnnotations);
520
- id = this.changeAnnotations.manage(annotation);
521
- edit = AnnotatedTextEdit.replace(range, newText, id);
522
- }
523
- this.edits.push(edit);
524
- if (id !== void 0) {
525
- return id;
526
- }
527
- };
528
- TextEditChangeImpl2.prototype.delete = function(range, annotation) {
529
- var edit;
530
- var id;
531
- if (annotation === void 0) {
532
- edit = TextEdit.del(range);
533
- } else if (ChangeAnnotationIdentifier.is(annotation)) {
534
- id = annotation;
535
- edit = AnnotatedTextEdit.del(range, annotation);
536
- } else {
537
- this.assertChangeAnnotations(this.changeAnnotations);
538
- id = this.changeAnnotations.manage(annotation);
539
- edit = AnnotatedTextEdit.del(range, id);
540
- }
541
- this.edits.push(edit);
542
- if (id !== void 0) {
543
- return id;
544
- }
545
- };
546
- TextEditChangeImpl2.prototype.add = function(edit) {
547
- this.edits.push(edit);
548
- };
549
- TextEditChangeImpl2.prototype.all = function() {
550
- return this.edits;
551
- };
552
- TextEditChangeImpl2.prototype.clear = function() {
553
- this.edits.splice(0, this.edits.length);
554
- };
555
- TextEditChangeImpl2.prototype.assertChangeAnnotations = function(value) {
556
- if (value === void 0) {
557
- throw new Error("Text edit change is not configured to manage change annotations.");
558
- }
559
- };
560
- return TextEditChangeImpl2;
561
- }();
562
- var ChangeAnnotations = function() {
563
- function ChangeAnnotations2(annotations) {
564
- this._annotations = annotations === void 0 ? /* @__PURE__ */ Object.create(null) : annotations;
565
- this._counter = 0;
566
- this._size = 0;
567
- }
568
- ChangeAnnotations2.prototype.all = function() {
569
- return this._annotations;
570
- };
571
- Object.defineProperty(ChangeAnnotations2.prototype, "size", {
572
- get: function() {
573
- return this._size;
574
- },
575
- enumerable: false,
576
- configurable: true
577
- });
578
- ChangeAnnotations2.prototype.manage = function(idOrAnnotation, annotation) {
579
- var id;
580
- if (ChangeAnnotationIdentifier.is(idOrAnnotation)) {
581
- id = idOrAnnotation;
582
- } else {
583
- id = this.nextId();
584
- annotation = idOrAnnotation;
585
- }
586
- if (this._annotations[id] !== void 0) {
587
- throw new Error("Id " + id + " is already in use.");
588
- }
589
- if (annotation === void 0) {
590
- throw new Error("No annotation provided for id " + id);
591
- }
592
- this._annotations[id] = annotation;
593
- this._size++;
594
- return id;
595
- };
596
- ChangeAnnotations2.prototype.nextId = function() {
597
- this._counter++;
598
- return this._counter.toString();
599
- };
600
- return ChangeAnnotations2;
601
- }();
602
- (function() {
603
- function WorkspaceChange2(workspaceEdit) {
604
- var _this = this;
605
- this._textEditChanges = /* @__PURE__ */ Object.create(null);
606
- if (workspaceEdit !== void 0) {
607
- this._workspaceEdit = workspaceEdit;
608
- if (workspaceEdit.documentChanges) {
609
- this._changeAnnotations = new ChangeAnnotations(workspaceEdit.changeAnnotations);
610
- workspaceEdit.changeAnnotations = this._changeAnnotations.all();
611
- workspaceEdit.documentChanges.forEach(function(change) {
612
- if (TextDocumentEdit.is(change)) {
613
- var textEditChange = new TextEditChangeImpl(change.edits, _this._changeAnnotations);
614
- _this._textEditChanges[change.textDocument.uri] = textEditChange;
615
- }
616
- });
617
- } else if (workspaceEdit.changes) {
618
- Object.keys(workspaceEdit.changes).forEach(function(key) {
619
- var textEditChange = new TextEditChangeImpl(workspaceEdit.changes[key]);
620
- _this._textEditChanges[key] = textEditChange;
621
- });
622
- }
623
- } else {
624
- this._workspaceEdit = {};
625
- }
626
- }
627
- Object.defineProperty(WorkspaceChange2.prototype, "edit", {
628
- get: function() {
629
- this.initDocumentChanges();
630
- if (this._changeAnnotations !== void 0) {
631
- if (this._changeAnnotations.size === 0) {
632
- this._workspaceEdit.changeAnnotations = void 0;
633
- } else {
634
- this._workspaceEdit.changeAnnotations = this._changeAnnotations.all();
635
- }
636
- }
637
- return this._workspaceEdit;
638
- },
639
- enumerable: false,
640
- configurable: true
641
- });
642
- WorkspaceChange2.prototype.getTextEditChange = function(key) {
643
- if (OptionalVersionedTextDocumentIdentifier.is(key)) {
644
- this.initDocumentChanges();
645
- if (this._workspaceEdit.documentChanges === void 0) {
646
- throw new Error("Workspace edit is not configured for document changes.");
647
- }
648
- var textDocument = { uri: key.uri, version: key.version };
649
- var result = this._textEditChanges[textDocument.uri];
650
- if (!result) {
651
- var edits = [];
652
- var textDocumentEdit = {
653
- textDocument,
654
- edits
655
- };
656
- this._workspaceEdit.documentChanges.push(textDocumentEdit);
657
- result = new TextEditChangeImpl(edits, this._changeAnnotations);
658
- this._textEditChanges[textDocument.uri] = result;
659
- }
660
- return result;
661
- } else {
662
- this.initChanges();
663
- if (this._workspaceEdit.changes === void 0) {
664
- throw new Error("Workspace edit is not configured for normal text edit changes.");
665
- }
666
- var result = this._textEditChanges[key];
667
- if (!result) {
668
- var edits = [];
669
- this._workspaceEdit.changes[key] = edits;
670
- result = new TextEditChangeImpl(edits);
671
- this._textEditChanges[key] = result;
672
- }
673
- return result;
674
- }
675
- };
676
- WorkspaceChange2.prototype.initDocumentChanges = function() {
677
- if (this._workspaceEdit.documentChanges === void 0 && this._workspaceEdit.changes === void 0) {
678
- this._changeAnnotations = new ChangeAnnotations();
679
- this._workspaceEdit.documentChanges = [];
680
- this._workspaceEdit.changeAnnotations = this._changeAnnotations.all();
681
- }
682
- };
683
- WorkspaceChange2.prototype.initChanges = function() {
684
- if (this._workspaceEdit.documentChanges === void 0 && this._workspaceEdit.changes === void 0) {
685
- this._workspaceEdit.changes = /* @__PURE__ */ Object.create(null);
686
- }
687
- };
688
- WorkspaceChange2.prototype.createFile = function(uri, optionsOrAnnotation, options) {
689
- this.initDocumentChanges();
690
- if (this._workspaceEdit.documentChanges === void 0) {
691
- throw new Error("Workspace edit is not configured for document changes.");
692
- }
693
- var annotation;
694
- if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) {
695
- annotation = optionsOrAnnotation;
696
- } else {
697
- options = optionsOrAnnotation;
698
- }
699
- var operation;
700
- var id;
701
- if (annotation === void 0) {
702
- operation = CreateFile.create(uri, options);
703
- } else {
704
- id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation);
705
- operation = CreateFile.create(uri, options, id);
706
- }
707
- this._workspaceEdit.documentChanges.push(operation);
708
- if (id !== void 0) {
709
- return id;
710
- }
711
- };
712
- WorkspaceChange2.prototype.renameFile = function(oldUri, newUri, optionsOrAnnotation, options) {
713
- this.initDocumentChanges();
714
- if (this._workspaceEdit.documentChanges === void 0) {
715
- throw new Error("Workspace edit is not configured for document changes.");
716
- }
717
- var annotation;
718
- if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) {
719
- annotation = optionsOrAnnotation;
720
- } else {
721
- options = optionsOrAnnotation;
722
- }
723
- var operation;
724
- var id;
725
- if (annotation === void 0) {
726
- operation = RenameFile.create(oldUri, newUri, options);
727
- } else {
728
- id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation);
729
- operation = RenameFile.create(oldUri, newUri, options, id);
730
- }
731
- this._workspaceEdit.documentChanges.push(operation);
732
- if (id !== void 0) {
733
- return id;
734
- }
735
- };
736
- WorkspaceChange2.prototype.deleteFile = function(uri, optionsOrAnnotation, options) {
737
- this.initDocumentChanges();
738
- if (this._workspaceEdit.documentChanges === void 0) {
739
- throw new Error("Workspace edit is not configured for document changes.");
740
- }
741
- var annotation;
742
- if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) {
743
- annotation = optionsOrAnnotation;
744
- } else {
745
- options = optionsOrAnnotation;
746
- }
747
- var operation;
748
- var id;
749
- if (annotation === void 0) {
750
- operation = DeleteFile.create(uri, options);
751
- } else {
752
- id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation);
753
- operation = DeleteFile.create(uri, options, id);
754
- }
755
- this._workspaceEdit.documentChanges.push(operation);
756
- if (id !== void 0) {
757
- return id;
758
- }
759
- };
760
- return WorkspaceChange2;
761
- })();
762
- var TextDocumentIdentifier;
763
- (function(TextDocumentIdentifier2) {
764
- function create(uri) {
765
- return { uri };
766
- }
767
- TextDocumentIdentifier2.create = create;
768
- function is(value) {
769
- var candidate = value;
770
- return Is.defined(candidate) && Is.string(candidate.uri);
771
- }
772
- TextDocumentIdentifier2.is = is;
773
- })(TextDocumentIdentifier || (TextDocumentIdentifier = {}));
774
- var VersionedTextDocumentIdentifier;
775
- (function(VersionedTextDocumentIdentifier2) {
776
- function create(uri, version) {
777
- return { uri, version };
778
- }
779
- VersionedTextDocumentIdentifier2.create = create;
780
- function is(value) {
781
- var candidate = value;
782
- return Is.defined(candidate) && Is.string(candidate.uri) && Is.integer(candidate.version);
783
- }
784
- VersionedTextDocumentIdentifier2.is = is;
785
- })(VersionedTextDocumentIdentifier || (VersionedTextDocumentIdentifier = {}));
786
- var OptionalVersionedTextDocumentIdentifier;
787
- (function(OptionalVersionedTextDocumentIdentifier2) {
788
- function create(uri, version) {
789
- return { uri, version };
790
- }
791
- OptionalVersionedTextDocumentIdentifier2.create = create;
792
- function is(value) {
793
- var candidate = value;
794
- return Is.defined(candidate) && Is.string(candidate.uri) && (candidate.version === null || Is.integer(candidate.version));
795
- }
796
- OptionalVersionedTextDocumentIdentifier2.is = is;
797
- })(OptionalVersionedTextDocumentIdentifier || (OptionalVersionedTextDocumentIdentifier = {}));
798
- var TextDocumentItem;
799
- (function(TextDocumentItem2) {
800
- function create(uri, languageId, version, text) {
801
- return { uri, languageId, version, text };
802
- }
803
- TextDocumentItem2.create = create;
804
- function is(value) {
805
- var candidate = value;
806
- return Is.defined(candidate) && Is.string(candidate.uri) && Is.string(candidate.languageId) && Is.integer(candidate.version) && Is.string(candidate.text);
807
- }
808
- TextDocumentItem2.is = is;
809
- })(TextDocumentItem || (TextDocumentItem = {}));
810
- var MarkupKind;
811
- (function(MarkupKind2) {
812
- MarkupKind2.PlainText = "plaintext";
813
- MarkupKind2.Markdown = "markdown";
814
- })(MarkupKind || (MarkupKind = {}));
815
- (function(MarkupKind2) {
816
- function is(value) {
817
- var candidate = value;
818
- return candidate === MarkupKind2.PlainText || candidate === MarkupKind2.Markdown;
819
- }
820
- MarkupKind2.is = is;
821
- })(MarkupKind || (MarkupKind = {}));
822
- var MarkupContent;
823
- (function(MarkupContent2) {
824
- function is(value) {
825
- var candidate = value;
826
- return Is.objectLiteral(value) && MarkupKind.is(candidate.kind) && Is.string(candidate.value);
827
- }
828
- MarkupContent2.is = is;
829
- })(MarkupContent || (MarkupContent = {}));
830
- var CompletionItemKind;
831
- (function(CompletionItemKind2) {
832
- CompletionItemKind2.Text = 1;
833
- CompletionItemKind2.Method = 2;
834
- CompletionItemKind2.Function = 3;
835
- CompletionItemKind2.Constructor = 4;
836
- CompletionItemKind2.Field = 5;
837
- CompletionItemKind2.Variable = 6;
838
- CompletionItemKind2.Class = 7;
839
- CompletionItemKind2.Interface = 8;
840
- CompletionItemKind2.Module = 9;
841
- CompletionItemKind2.Property = 10;
842
- CompletionItemKind2.Unit = 11;
843
- CompletionItemKind2.Value = 12;
844
- CompletionItemKind2.Enum = 13;
845
- CompletionItemKind2.Keyword = 14;
846
- CompletionItemKind2.Snippet = 15;
847
- CompletionItemKind2.Color = 16;
848
- CompletionItemKind2.File = 17;
849
- CompletionItemKind2.Reference = 18;
850
- CompletionItemKind2.Folder = 19;
851
- CompletionItemKind2.EnumMember = 20;
852
- CompletionItemKind2.Constant = 21;
853
- CompletionItemKind2.Struct = 22;
854
- CompletionItemKind2.Event = 23;
855
- CompletionItemKind2.Operator = 24;
856
- CompletionItemKind2.TypeParameter = 25;
857
- })(CompletionItemKind || (CompletionItemKind = {}));
858
- var InsertTextFormat;
859
- (function(InsertTextFormat2) {
860
- InsertTextFormat2.PlainText = 1;
861
- InsertTextFormat2.Snippet = 2;
862
- })(InsertTextFormat || (InsertTextFormat = {}));
863
- var CompletionItemTag;
864
- (function(CompletionItemTag2) {
865
- CompletionItemTag2.Deprecated = 1;
866
- })(CompletionItemTag || (CompletionItemTag = {}));
867
- var InsertReplaceEdit;
868
- (function(InsertReplaceEdit2) {
869
- function create(newText, insert, replace) {
870
- return { newText, insert, replace };
871
- }
872
- InsertReplaceEdit2.create = create;
873
- function is(value) {
874
- var candidate = value;
875
- return candidate && Is.string(candidate.newText) && Range.is(candidate.insert) && Range.is(candidate.replace);
876
- }
877
- InsertReplaceEdit2.is = is;
878
- })(InsertReplaceEdit || (InsertReplaceEdit = {}));
879
- var InsertTextMode;
880
- (function(InsertTextMode2) {
881
- InsertTextMode2.asIs = 1;
882
- InsertTextMode2.adjustIndentation = 2;
883
- })(InsertTextMode || (InsertTextMode = {}));
884
- var CompletionItem;
885
- (function(CompletionItem2) {
886
- function create(label) {
887
- return { label };
888
- }
889
- CompletionItem2.create = create;
890
- })(CompletionItem || (CompletionItem = {}));
891
- var CompletionList;
892
- (function(CompletionList2) {
893
- function create(items, isIncomplete) {
894
- return { items: items ? items : [], isIncomplete: !!isIncomplete };
895
- }
896
- CompletionList2.create = create;
897
- })(CompletionList || (CompletionList = {}));
898
- var MarkedString;
899
- (function(MarkedString2) {
900
- function fromPlainText(plainText) {
901
- return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&");
902
- }
903
- MarkedString2.fromPlainText = fromPlainText;
904
- function is(value) {
905
- var candidate = value;
906
- return Is.string(candidate) || Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value);
907
- }
908
- MarkedString2.is = is;
909
- })(MarkedString || (MarkedString = {}));
910
- var Hover;
911
- (function(Hover2) {
912
- function is(value) {
913
- var candidate = value;
914
- return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) || MarkedString.is(candidate.contents) || Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === void 0 || Range.is(value.range));
915
- }
916
- Hover2.is = is;
917
- })(Hover || (Hover = {}));
918
- var ParameterInformation;
919
- (function(ParameterInformation2) {
920
- function create(label, documentation) {
921
- return documentation ? { label, documentation } : { label };
922
- }
923
- ParameterInformation2.create = create;
924
- })(ParameterInformation || (ParameterInformation = {}));
925
- var SignatureInformation;
926
- (function(SignatureInformation2) {
927
- function create(label, documentation) {
928
- var parameters = [];
929
- for (var _i = 2; _i < arguments.length; _i++) {
930
- parameters[_i - 2] = arguments[_i];
931
- }
932
- var result = { label };
933
- if (Is.defined(documentation)) {
934
- result.documentation = documentation;
935
- }
936
- if (Is.defined(parameters)) {
937
- result.parameters = parameters;
938
- } else {
939
- result.parameters = [];
940
- }
941
- return result;
942
- }
943
- SignatureInformation2.create = create;
944
- })(SignatureInformation || (SignatureInformation = {}));
945
- var DocumentHighlightKind;
946
- (function(DocumentHighlightKind2) {
947
- DocumentHighlightKind2.Text = 1;
948
- DocumentHighlightKind2.Read = 2;
949
- DocumentHighlightKind2.Write = 3;
950
- })(DocumentHighlightKind || (DocumentHighlightKind = {}));
951
- var DocumentHighlight;
952
- (function(DocumentHighlight2) {
953
- function create(range, kind) {
954
- var result = { range };
955
- if (Is.number(kind)) {
956
- result.kind = kind;
957
- }
958
- return result;
959
- }
960
- DocumentHighlight2.create = create;
961
- })(DocumentHighlight || (DocumentHighlight = {}));
962
- var SymbolKind;
963
- (function(SymbolKind2) {
964
- SymbolKind2.File = 1;
965
- SymbolKind2.Module = 2;
966
- SymbolKind2.Namespace = 3;
967
- SymbolKind2.Package = 4;
968
- SymbolKind2.Class = 5;
969
- SymbolKind2.Method = 6;
970
- SymbolKind2.Property = 7;
971
- SymbolKind2.Field = 8;
972
- SymbolKind2.Constructor = 9;
973
- SymbolKind2.Enum = 10;
974
- SymbolKind2.Interface = 11;
975
- SymbolKind2.Function = 12;
976
- SymbolKind2.Variable = 13;
977
- SymbolKind2.Constant = 14;
978
- SymbolKind2.String = 15;
979
- SymbolKind2.Number = 16;
980
- SymbolKind2.Boolean = 17;
981
- SymbolKind2.Array = 18;
982
- SymbolKind2.Object = 19;
983
- SymbolKind2.Key = 20;
984
- SymbolKind2.Null = 21;
985
- SymbolKind2.EnumMember = 22;
986
- SymbolKind2.Struct = 23;
987
- SymbolKind2.Event = 24;
988
- SymbolKind2.Operator = 25;
989
- SymbolKind2.TypeParameter = 26;
990
- })(SymbolKind || (SymbolKind = {}));
991
- var SymbolTag;
992
- (function(SymbolTag2) {
993
- SymbolTag2.Deprecated = 1;
994
- })(SymbolTag || (SymbolTag = {}));
995
- var SymbolInformation;
996
- (function(SymbolInformation2) {
997
- function create(name, kind, range, uri, containerName) {
998
- var result = {
999
- name,
1000
- kind,
1001
- location: { uri, range }
1002
- };
1003
- if (containerName) {
1004
- result.containerName = containerName;
1005
- }
1006
- return result;
1007
- }
1008
- SymbolInformation2.create = create;
1009
- })(SymbolInformation || (SymbolInformation = {}));
1010
- var DocumentSymbol;
1011
- (function(DocumentSymbol2) {
1012
- function create(name, detail, kind, range, selectionRange, children) {
1013
- var result = {
1014
- name,
1015
- detail,
1016
- kind,
1017
- range,
1018
- selectionRange
1019
- };
1020
- if (children !== void 0) {
1021
- result.children = children;
1022
- }
1023
- return result;
1024
- }
1025
- DocumentSymbol2.create = create;
1026
- function is(value) {
1027
- var candidate = value;
1028
- return candidate && Is.string(candidate.name) && Is.number(candidate.kind) && Range.is(candidate.range) && Range.is(candidate.selectionRange) && (candidate.detail === void 0 || Is.string(candidate.detail)) && (candidate.deprecated === void 0 || Is.boolean(candidate.deprecated)) && (candidate.children === void 0 || Array.isArray(candidate.children)) && (candidate.tags === void 0 || Array.isArray(candidate.tags));
1029
- }
1030
- DocumentSymbol2.is = is;
1031
- })(DocumentSymbol || (DocumentSymbol = {}));
1032
- var CodeActionKind;
1033
- (function(CodeActionKind2) {
1034
- CodeActionKind2.Empty = "";
1035
- CodeActionKind2.QuickFix = "quickfix";
1036
- CodeActionKind2.Refactor = "refactor";
1037
- CodeActionKind2.RefactorExtract = "refactor.extract";
1038
- CodeActionKind2.RefactorInline = "refactor.inline";
1039
- CodeActionKind2.RefactorRewrite = "refactor.rewrite";
1040
- CodeActionKind2.Source = "source";
1041
- CodeActionKind2.SourceOrganizeImports = "source.organizeImports";
1042
- CodeActionKind2.SourceFixAll = "source.fixAll";
1043
- })(CodeActionKind || (CodeActionKind = {}));
1044
- var CodeActionContext;
1045
- (function(CodeActionContext2) {
1046
- function create(diagnostics, only) {
1047
- var result = { diagnostics };
1048
- if (only !== void 0 && only !== null) {
1049
- result.only = only;
1050
- }
1051
- return result;
1052
- }
1053
- CodeActionContext2.create = create;
1054
- function is(value) {
1055
- var candidate = value;
1056
- return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic.is) && (candidate.only === void 0 || Is.typedArray(candidate.only, Is.string));
1057
- }
1058
- CodeActionContext2.is = is;
1059
- })(CodeActionContext || (CodeActionContext = {}));
1060
- var CodeAction;
1061
- (function(CodeAction2) {
1062
- function create(title, kindOrCommandOrEdit, kind) {
1063
- var result = { title };
1064
- var checkKind = true;
1065
- if (typeof kindOrCommandOrEdit === "string") {
1066
- checkKind = false;
1067
- result.kind = kindOrCommandOrEdit;
1068
- } else if (Command.is(kindOrCommandOrEdit)) {
1069
- result.command = kindOrCommandOrEdit;
1070
- } else {
1071
- result.edit = kindOrCommandOrEdit;
1072
- }
1073
- if (checkKind && kind !== void 0) {
1074
- result.kind = kind;
1075
- }
1076
- return result;
1077
- }
1078
- CodeAction2.create = create;
1079
- function is(value) {
1080
- var candidate = value;
1081
- return candidate && Is.string(candidate.title) && (candidate.diagnostics === void 0 || Is.typedArray(candidate.diagnostics, Diagnostic.is)) && (candidate.kind === void 0 || Is.string(candidate.kind)) && (candidate.edit !== void 0 || candidate.command !== void 0) && (candidate.command === void 0 || Command.is(candidate.command)) && (candidate.isPreferred === void 0 || Is.boolean(candidate.isPreferred)) && (candidate.edit === void 0 || WorkspaceEdit.is(candidate.edit));
1082
- }
1083
- CodeAction2.is = is;
1084
- })(CodeAction || (CodeAction = {}));
1085
- var CodeLens;
1086
- (function(CodeLens2) {
1087
- function create(range, data) {
1088
- var result = { range };
1089
- if (Is.defined(data)) {
1090
- result.data = data;
1091
- }
1092
- return result;
1093
- }
1094
- CodeLens2.create = create;
1095
- function is(value) {
1096
- var candidate = value;
1097
- return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
1098
- }
1099
- CodeLens2.is = is;
1100
- })(CodeLens || (CodeLens = {}));
1101
- var FormattingOptions;
1102
- (function(FormattingOptions2) {
1103
- function create(tabSize, insertSpaces) {
1104
- return { tabSize, insertSpaces };
1105
- }
1106
- FormattingOptions2.create = create;
1107
- function is(value) {
1108
- var candidate = value;
1109
- return Is.defined(candidate) && Is.uinteger(candidate.tabSize) && Is.boolean(candidate.insertSpaces);
1110
- }
1111
- FormattingOptions2.is = is;
1112
- })(FormattingOptions || (FormattingOptions = {}));
1113
- var DocumentLink;
1114
- (function(DocumentLink2) {
1115
- function create(range, target, data) {
1116
- return { range, target, data };
1117
- }
1118
- DocumentLink2.create = create;
1119
- function is(value) {
1120
- var candidate = value;
1121
- return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
1122
- }
1123
- DocumentLink2.is = is;
1124
- })(DocumentLink || (DocumentLink = {}));
1125
- var SelectionRange;
1126
- (function(SelectionRange2) {
1127
- function create(range, parent) {
1128
- return { range, parent };
1129
- }
1130
- SelectionRange2.create = create;
1131
- function is(value) {
1132
- var candidate = value;
1133
- return candidate !== void 0 && Range.is(candidate.range) && (candidate.parent === void 0 || SelectionRange2.is(candidate.parent));
1134
- }
1135
- SelectionRange2.is = is;
1136
- })(SelectionRange || (SelectionRange = {}));
1137
- var TextDocument;
1138
- (function(TextDocument2) {
1139
- function create(uri, languageId, version, content) {
1140
- return new FullTextDocument(uri, languageId, version, content);
1141
- }
1142
- TextDocument2.create = create;
1143
- function is(value) {
1144
- var candidate = value;
1145
- return Is.defined(candidate) && Is.string(candidate.uri) && (Is.undefined(candidate.languageId) || Is.string(candidate.languageId)) && Is.uinteger(candidate.lineCount) && Is.func(candidate.getText) && Is.func(candidate.positionAt) && Is.func(candidate.offsetAt) ? true : false;
1146
- }
1147
- TextDocument2.is = is;
1148
- function applyEdits(document, edits) {
1149
- var text = document.getText();
1150
- var sortedEdits = mergeSort(edits, function(a, b) {
1151
- var diff = a.range.start.line - b.range.start.line;
1152
- if (diff === 0) {
1153
- return a.range.start.character - b.range.start.character;
1154
- }
1155
- return diff;
1156
- });
1157
- var lastModifiedOffset = text.length;
1158
- for (var i = sortedEdits.length - 1; i >= 0; i--) {
1159
- var e = sortedEdits[i];
1160
- var startOffset = document.offsetAt(e.range.start);
1161
- var endOffset = document.offsetAt(e.range.end);
1162
- if (endOffset <= lastModifiedOffset) {
1163
- text = text.substring(0, startOffset) + e.newText + text.substring(endOffset, text.length);
1164
- } else {
1165
- throw new Error("Overlapping edit");
1166
- }
1167
- lastModifiedOffset = startOffset;
1168
- }
1169
- return text;
1170
- }
1171
- TextDocument2.applyEdits = applyEdits;
1172
- function mergeSort(data, compare) {
1173
- if (data.length <= 1) {
1174
- return data;
1175
- }
1176
- var p = data.length / 2 | 0;
1177
- var left = data.slice(0, p);
1178
- var right = data.slice(p);
1179
- mergeSort(left, compare);
1180
- mergeSort(right, compare);
1181
- var leftIdx = 0;
1182
- var rightIdx = 0;
1183
- var i = 0;
1184
- while (leftIdx < left.length && rightIdx < right.length) {
1185
- var ret = compare(left[leftIdx], right[rightIdx]);
1186
- if (ret <= 0) {
1187
- data[i++] = left[leftIdx++];
1188
- } else {
1189
- data[i++] = right[rightIdx++];
1190
- }
1191
- }
1192
- while (leftIdx < left.length) {
1193
- data[i++] = left[leftIdx++];
1194
- }
1195
- while (rightIdx < right.length) {
1196
- data[i++] = right[rightIdx++];
1197
- }
1198
- return data;
1199
- }
1200
- })(TextDocument || (TextDocument = {}));
1201
- var FullTextDocument = function() {
1202
- function FullTextDocument2(uri, languageId, version, content) {
1203
- this._uri = uri;
1204
- this._languageId = languageId;
1205
- this._version = version;
1206
- this._content = content;
1207
- this._lineOffsets = void 0;
1208
- }
1209
- Object.defineProperty(FullTextDocument2.prototype, "uri", {
1210
- get: function() {
1211
- return this._uri;
1212
- },
1213
- enumerable: false,
1214
- configurable: true
1215
- });
1216
- Object.defineProperty(FullTextDocument2.prototype, "languageId", {
1217
- get: function() {
1218
- return this._languageId;
1219
- },
1220
- enumerable: false,
1221
- configurable: true
1222
- });
1223
- Object.defineProperty(FullTextDocument2.prototype, "version", {
1224
- get: function() {
1225
- return this._version;
1226
- },
1227
- enumerable: false,
1228
- configurable: true
1229
- });
1230
- FullTextDocument2.prototype.getText = function(range) {
1231
- if (range) {
1232
- var start = this.offsetAt(range.start);
1233
- var end = this.offsetAt(range.end);
1234
- return this._content.substring(start, end);
1235
- }
1236
- return this._content;
1237
- };
1238
- FullTextDocument2.prototype.update = function(event, version) {
1239
- this._content = event.text;
1240
- this._version = version;
1241
- this._lineOffsets = void 0;
1242
- };
1243
- FullTextDocument2.prototype.getLineOffsets = function() {
1244
- if (this._lineOffsets === void 0) {
1245
- var lineOffsets = [];
1246
- var text = this._content;
1247
- var isLineStart = true;
1248
- for (var i = 0; i < text.length; i++) {
1249
- if (isLineStart) {
1250
- lineOffsets.push(i);
1251
- isLineStart = false;
1252
- }
1253
- var ch = text.charAt(i);
1254
- isLineStart = ch === "\r" || ch === "\n";
1255
- if (ch === "\r" && i + 1 < text.length && text.charAt(i + 1) === "\n") {
1256
- i++;
1257
- }
1258
- }
1259
- if (isLineStart && text.length > 0) {
1260
- lineOffsets.push(text.length);
1261
- }
1262
- this._lineOffsets = lineOffsets;
1263
- }
1264
- return this._lineOffsets;
1265
- };
1266
- FullTextDocument2.prototype.positionAt = function(offset) {
1267
- offset = Math.max(Math.min(offset, this._content.length), 0);
1268
- var lineOffsets = this.getLineOffsets();
1269
- var low = 0, high = lineOffsets.length;
1270
- if (high === 0) {
1271
- return Position.create(0, offset);
1272
- }
1273
- while (low < high) {
1274
- var mid = Math.floor((low + high) / 2);
1275
- if (lineOffsets[mid] > offset) {
1276
- high = mid;
1277
- } else {
1278
- low = mid + 1;
1279
- }
1280
- }
1281
- var line = low - 1;
1282
- return Position.create(line, offset - lineOffsets[line]);
1283
- };
1284
- FullTextDocument2.prototype.offsetAt = function(position) {
1285
- var lineOffsets = this.getLineOffsets();
1286
- if (position.line >= lineOffsets.length) {
1287
- return this._content.length;
1288
- } else if (position.line < 0) {
1289
- return 0;
1290
- }
1291
- var lineOffset = lineOffsets[position.line];
1292
- var nextLineOffset = position.line + 1 < lineOffsets.length ? lineOffsets[position.line + 1] : this._content.length;
1293
- return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);
1294
- };
1295
- Object.defineProperty(FullTextDocument2.prototype, "lineCount", {
1296
- get: function() {
1297
- return this.getLineOffsets().length;
1298
- },
1299
- enumerable: false,
1300
- configurable: true
1301
- });
1302
- return FullTextDocument2;
1303
- }();
1304
- var Is;
1305
- (function(Is2) {
1306
- var toString = Object.prototype.toString;
1307
- function defined(value) {
1308
- return typeof value !== "undefined";
1309
- }
1310
- Is2.defined = defined;
1311
- function undefined2(value) {
1312
- return typeof value === "undefined";
1313
- }
1314
- Is2.undefined = undefined2;
1315
- function boolean(value) {
1316
- return value === true || value === false;
1317
- }
1318
- Is2.boolean = boolean;
1319
- function string(value) {
1320
- return toString.call(value) === "[object String]";
1321
- }
1322
- Is2.string = string;
1323
- function number(value) {
1324
- return toString.call(value) === "[object Number]";
1325
- }
1326
- Is2.number = number;
1327
- function numberRange(value, min, max) {
1328
- return toString.call(value) === "[object Number]" && min <= value && value <= max;
1329
- }
1330
- Is2.numberRange = numberRange;
1331
- function integer2(value) {
1332
- return toString.call(value) === "[object Number]" && -2147483648 <= value && value <= 2147483647;
1333
- }
1334
- Is2.integer = integer2;
1335
- function uinteger2(value) {
1336
- return toString.call(value) === "[object Number]" && 0 <= value && value <= 2147483647;
1337
- }
1338
- Is2.uinteger = uinteger2;
1339
- function func(value) {
1340
- return toString.call(value) === "[object Function]";
1341
- }
1342
- Is2.func = func;
1343
- function objectLiteral(value) {
1344
- return value !== null && typeof value === "object";
1345
- }
1346
- Is2.objectLiteral = objectLiteral;
1347
- function typedArray(value, check) {
1348
- return Array.isArray(value) && value.every(check);
1349
- }
1350
- Is2.typedArray = typedArray;
1351
- })(Is || (Is = {}));
1352
-
1353
- // src/language/common/lspLanguageFeatures.ts
1354
- var DiagnosticsAdapter = class {
1355
- constructor(_languageId, _worker, configChangeEvent) {
1356
- this._languageId = _languageId;
1357
- this._worker = _worker;
1358
- const onModelAdd = (model) => {
1359
- let modeId = model.getLanguageId();
1360
- if (modeId !== this._languageId) {
1361
- return;
1362
- }
1363
- let handle;
1364
- this._listener[model.uri.toString()] = model.onDidChangeContent(() => {
1365
- window.clearTimeout(handle);
1366
- handle = window.setTimeout(() => this._doValidate(model.uri, modeId), 500);
1367
- });
1368
- this._doValidate(model.uri, modeId);
1369
- };
1370
- const onModelRemoved = (model) => {
1371
- monaco_editor_core_exports.editor.setModelMarkers(model, this._languageId, []);
1372
- let uriStr = model.uri.toString();
1373
- let listener = this._listener[uriStr];
1374
- if (listener) {
1375
- listener.dispose();
1376
- delete this._listener[uriStr];
1377
- }
1378
- };
1379
- this._disposables.push(monaco_editor_core_exports.editor.onDidCreateModel(onModelAdd));
1380
- this._disposables.push(monaco_editor_core_exports.editor.onWillDisposeModel(onModelRemoved));
1381
- this._disposables.push(monaco_editor_core_exports.editor.onDidChangeModelLanguage((event) => {
1382
- onModelRemoved(event.model);
1383
- onModelAdd(event.model);
1384
- }));
1385
- this._disposables.push(configChangeEvent((_) => {
1386
- monaco_editor_core_exports.editor.getModels().forEach((model) => {
1387
- if (model.getLanguageId() === this._languageId) {
1388
- onModelRemoved(model);
1389
- onModelAdd(model);
1390
- }
1391
- });
1392
- }));
1393
- this._disposables.push({
1394
- dispose: () => {
1395
- monaco_editor_core_exports.editor.getModels().forEach(onModelRemoved);
1396
- for (let key in this._listener) {
1397
- this._listener[key].dispose();
1398
- }
1399
- }
1400
- });
1401
- monaco_editor_core_exports.editor.getModels().forEach(onModelAdd);
1402
- }
1403
- _disposables = [];
1404
- _listener = /* @__PURE__ */ Object.create(null);
1405
- dispose() {
1406
- this._disposables.forEach((d) => d && d.dispose());
1407
- this._disposables.length = 0;
1408
- }
1409
- _doValidate(resource, languageId) {
1410
- this._worker(resource).then((worker) => {
1411
- return worker.doValidation(resource.toString());
1412
- }).then((diagnostics) => {
1413
- const markers = diagnostics.map((d) => toDiagnostics(resource, d));
1414
- let model = monaco_editor_core_exports.editor.getModel(resource);
1415
- if (model && model.getLanguageId() === languageId) {
1416
- monaco_editor_core_exports.editor.setModelMarkers(model, languageId, markers);
1417
- }
1418
- }).then(void 0, (err) => {
1419
- console.error(err);
1420
- });
1421
- }
1422
- };
1423
- function toSeverity(lsSeverity) {
1424
- switch (lsSeverity) {
1425
- case DiagnosticSeverity.Error:
1426
- return monaco_editor_core_exports.MarkerSeverity.Error;
1427
- case DiagnosticSeverity.Warning:
1428
- return monaco_editor_core_exports.MarkerSeverity.Warning;
1429
- case DiagnosticSeverity.Information:
1430
- return monaco_editor_core_exports.MarkerSeverity.Info;
1431
- case DiagnosticSeverity.Hint:
1432
- return monaco_editor_core_exports.MarkerSeverity.Hint;
1433
- default:
1434
- return monaco_editor_core_exports.MarkerSeverity.Info;
1435
- }
1436
- }
1437
- function toDiagnostics(resource, diag) {
1438
- let code = typeof diag.code === "number" ? String(diag.code) : diag.code;
1439
- return {
1440
- severity: toSeverity(diag.severity),
1441
- startLineNumber: diag.range.start.line + 1,
1442
- startColumn: diag.range.start.character + 1,
1443
- endLineNumber: diag.range.end.line + 1,
1444
- endColumn: diag.range.end.character + 1,
1445
- message: diag.message,
1446
- code,
1447
- source: diag.source
1448
- };
1449
- }
1450
- var CompletionAdapter = class {
1451
- constructor(_worker, _triggerCharacters) {
1452
- this._worker = _worker;
1453
- this._triggerCharacters = _triggerCharacters;
1454
- }
1455
- get triggerCharacters() {
1456
- return this._triggerCharacters;
1457
- }
1458
- provideCompletionItems(model, position, context, token) {
1459
- const resource = model.uri;
1460
- return this._worker(resource).then((worker) => {
1461
- return worker.doComplete(resource.toString(), fromPosition(position));
1462
- }).then((info) => {
1463
- if (!info) {
1464
- return;
1465
- }
1466
- const wordInfo = model.getWordUntilPosition(position);
1467
- const wordRange = new monaco_editor_core_exports.Range(position.lineNumber, wordInfo.startColumn, position.lineNumber, wordInfo.endColumn);
1468
- const items = info.items.map((entry) => {
1469
- const item = {
1470
- label: entry.label,
1471
- insertText: entry.insertText || entry.label,
1472
- sortText: entry.sortText,
1473
- filterText: entry.filterText,
1474
- documentation: entry.documentation,
1475
- detail: entry.detail,
1476
- command: toCommand(entry.command),
1477
- range: wordRange,
1478
- kind: toCompletionItemKind(entry.kind)
1479
- };
1480
- if (entry.textEdit) {
1481
- if (isInsertReplaceEdit(entry.textEdit)) {
1482
- item.range = {
1483
- insert: toRange(entry.textEdit.insert),
1484
- replace: toRange(entry.textEdit.replace)
1485
- };
1486
- } else {
1487
- item.range = toRange(entry.textEdit.range);
1488
- }
1489
- item.insertText = entry.textEdit.newText;
1490
- }
1491
- if (entry.additionalTextEdits) {
1492
- item.additionalTextEdits = entry.additionalTextEdits.map(toTextEdit);
1493
- }
1494
- if (entry.insertTextFormat === InsertTextFormat.Snippet) {
1495
- item.insertTextRules = monaco_editor_core_exports.languages.CompletionItemInsertTextRule.InsertAsSnippet;
1496
- }
1497
- return item;
1498
- });
1499
- return {
1500
- isIncomplete: info.isIncomplete,
1501
- suggestions: items
1502
- };
1503
- });
1504
- }
1505
- };
1506
- function fromPosition(position) {
1507
- if (!position) {
1508
- return void 0;
1509
- }
1510
- return { character: position.column - 1, line: position.lineNumber - 1 };
1511
- }
1512
- function fromRange(range) {
1513
- if (!range) {
1514
- return void 0;
1515
- }
1516
- return {
1517
- start: {
1518
- line: range.startLineNumber - 1,
1519
- character: range.startColumn - 1
1520
- },
1521
- end: { line: range.endLineNumber - 1, character: range.endColumn - 1 }
1522
- };
1523
- }
1524
- function toRange(range) {
1525
- if (!range) {
1526
- return void 0;
1527
- }
1528
- return new monaco_editor_core_exports.Range(range.start.line + 1, range.start.character + 1, range.end.line + 1, range.end.character + 1);
1529
- }
1530
- function isInsertReplaceEdit(edit) {
1531
- return typeof edit.insert !== "undefined" && typeof edit.replace !== "undefined";
1532
- }
1533
- function toCompletionItemKind(kind) {
1534
- const mItemKind = monaco_editor_core_exports.languages.CompletionItemKind;
1535
- switch (kind) {
1536
- case CompletionItemKind.Text:
1537
- return mItemKind.Text;
1538
- case CompletionItemKind.Method:
1539
- return mItemKind.Method;
1540
- case CompletionItemKind.Function:
1541
- return mItemKind.Function;
1542
- case CompletionItemKind.Constructor:
1543
- return mItemKind.Constructor;
1544
- case CompletionItemKind.Field:
1545
- return mItemKind.Field;
1546
- case CompletionItemKind.Variable:
1547
- return mItemKind.Variable;
1548
- case CompletionItemKind.Class:
1549
- return mItemKind.Class;
1550
- case CompletionItemKind.Interface:
1551
- return mItemKind.Interface;
1552
- case CompletionItemKind.Module:
1553
- return mItemKind.Module;
1554
- case CompletionItemKind.Property:
1555
- return mItemKind.Property;
1556
- case CompletionItemKind.Unit:
1557
- return mItemKind.Unit;
1558
- case CompletionItemKind.Value:
1559
- return mItemKind.Value;
1560
- case CompletionItemKind.Enum:
1561
- return mItemKind.Enum;
1562
- case CompletionItemKind.Keyword:
1563
- return mItemKind.Keyword;
1564
- case CompletionItemKind.Snippet:
1565
- return mItemKind.Snippet;
1566
- case CompletionItemKind.Color:
1567
- return mItemKind.Color;
1568
- case CompletionItemKind.File:
1569
- return mItemKind.File;
1570
- case CompletionItemKind.Reference:
1571
- return mItemKind.Reference;
1572
- }
1573
- return mItemKind.Property;
1574
- }
1575
- function toTextEdit(textEdit) {
1576
- if (!textEdit) {
1577
- return void 0;
1578
- }
1579
- return {
1580
- range: toRange(textEdit.range),
1581
- text: textEdit.newText
1582
- };
1583
- }
1584
- function toCommand(c) {
1585
- return c && c.command === "editor.action.triggerSuggest" ? { id: c.command, title: c.title, arguments: c.arguments } : void 0;
1586
- }
1587
- var HoverAdapter = class {
1588
- constructor(_worker) {
1589
- this._worker = _worker;
1590
- }
1591
- provideHover(model, position, token) {
1592
- let resource = model.uri;
1593
- return this._worker(resource).then((worker) => {
1594
- return worker.doHover(resource.toString(), fromPosition(position));
1595
- }).then((info) => {
1596
- if (!info) {
1597
- return;
1598
- }
1599
- return {
1600
- range: toRange(info.range),
1601
- contents: toMarkedStringArray(info.contents)
1602
- };
1603
- });
1604
- }
1605
- };
1606
- function isMarkupContent(thing) {
1607
- return thing && typeof thing === "object" && typeof thing.kind === "string";
1608
- }
1609
- function toMarkdownString(entry) {
1610
- if (typeof entry === "string") {
1611
- return {
1612
- value: entry
1613
- };
1614
- }
1615
- if (isMarkupContent(entry)) {
1616
- if (entry.kind === "plaintext") {
1617
- return {
1618
- value: entry.value.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&")
1619
- };
1620
- }
1621
- return {
1622
- value: entry.value
1623
- };
1624
- }
1625
- return { value: "```" + entry.language + "\n" + entry.value + "\n```\n" };
1626
- }
1627
- function toMarkedStringArray(contents) {
1628
- if (!contents) {
1629
- return void 0;
1630
- }
1631
- if (Array.isArray(contents)) {
1632
- return contents.map(toMarkdownString);
1633
- }
1634
- return [toMarkdownString(contents)];
1635
- }
1636
- var DocumentHighlightAdapter = class {
1637
- constructor(_worker) {
1638
- this._worker = _worker;
1639
- }
1640
- provideDocumentHighlights(model, position, token) {
1641
- const resource = model.uri;
1642
- return this._worker(resource).then((worker) => worker.findDocumentHighlights(resource.toString(), fromPosition(position))).then((entries) => {
1643
- if (!entries) {
1644
- return;
1645
- }
1646
- return entries.map((entry) => {
1647
- return {
1648
- range: toRange(entry.range),
1649
- kind: toDocumentHighlightKind(entry.kind)
1650
- };
1651
- });
1652
- });
1653
- }
1654
- };
1655
- function toDocumentHighlightKind(kind) {
1656
- switch (kind) {
1657
- case DocumentHighlightKind.Read:
1658
- return monaco_editor_core_exports.languages.DocumentHighlightKind.Read;
1659
- case DocumentHighlightKind.Write:
1660
- return monaco_editor_core_exports.languages.DocumentHighlightKind.Write;
1661
- case DocumentHighlightKind.Text:
1662
- return monaco_editor_core_exports.languages.DocumentHighlightKind.Text;
1663
- }
1664
- return monaco_editor_core_exports.languages.DocumentHighlightKind.Text;
1665
- }
1666
- var DefinitionAdapter = class {
1667
- constructor(_worker) {
1668
- this._worker = _worker;
1669
- }
1670
- provideDefinition(model, position, token) {
1671
- const resource = model.uri;
1672
- return this._worker(resource).then((worker) => {
1673
- return worker.findDefinition(resource.toString(), fromPosition(position));
1674
- }).then((definition) => {
1675
- if (!definition) {
1676
- return;
1677
- }
1678
- return [toLocation(definition)];
1679
- });
1680
- }
1681
- };
1682
- function toLocation(location) {
1683
- return {
1684
- uri: monaco_editor_core_exports.Uri.parse(location.uri),
1685
- range: toRange(location.range)
1686
- };
1687
- }
1688
- var ReferenceAdapter = class {
1689
- constructor(_worker) {
1690
- this._worker = _worker;
1691
- }
1692
- provideReferences(model, position, context, token) {
1693
- const resource = model.uri;
1694
- return this._worker(resource).then((worker) => {
1695
- return worker.findReferences(resource.toString(), fromPosition(position));
1696
- }).then((entries) => {
1697
- if (!entries) {
1698
- return;
1699
- }
1700
- return entries.map(toLocation);
1701
- });
1702
- }
1703
- };
1704
- var RenameAdapter = class {
1705
- constructor(_worker) {
1706
- this._worker = _worker;
1707
- }
1708
- provideRenameEdits(model, position, newName, token) {
1709
- const resource = model.uri;
1710
- return this._worker(resource).then((worker) => {
1711
- return worker.doRename(resource.toString(), fromPosition(position), newName);
1712
- }).then((edit) => {
1713
- return toWorkspaceEdit(edit);
1714
- });
1715
- }
1716
- };
1717
- function toWorkspaceEdit(edit) {
1718
- if (!edit || !edit.changes) {
1719
- return void 0;
1720
- }
1721
- let resourceEdits = [];
1722
- for (let uri in edit.changes) {
1723
- const _uri = monaco_editor_core_exports.Uri.parse(uri);
1724
- for (let e of edit.changes[uri]) {
1725
- resourceEdits.push({
1726
- resource: _uri,
1727
- versionId: void 0,
1728
- textEdit: {
1729
- range: toRange(e.range),
1730
- text: e.newText
1731
- }
1732
- });
1733
- }
1734
- }
1735
- return {
1736
- edits: resourceEdits
1737
- };
1738
- }
1739
- var DocumentSymbolAdapter = class {
1740
- constructor(_worker) {
1741
- this._worker = _worker;
1742
- }
1743
- provideDocumentSymbols(model, token) {
1744
- const resource = model.uri;
1745
- return this._worker(resource).then((worker) => worker.findDocumentSymbols(resource.toString())).then((items) => {
1746
- if (!items) {
1747
- return;
1748
- }
1749
- return items.map((item) => ({
1750
- name: item.name,
1751
- detail: "",
1752
- containerName: item.containerName,
1753
- kind: toSymbolKind(item.kind),
1754
- range: toRange(item.location.range),
1755
- selectionRange: toRange(item.location.range),
1756
- tags: []
1757
- }));
1758
- });
1759
- }
1760
- };
1761
- function toSymbolKind(kind) {
1762
- let mKind = monaco_editor_core_exports.languages.SymbolKind;
1763
- switch (kind) {
1764
- case SymbolKind.File:
1765
- return mKind.Array;
1766
- case SymbolKind.Module:
1767
- return mKind.Module;
1768
- case SymbolKind.Namespace:
1769
- return mKind.Namespace;
1770
- case SymbolKind.Package:
1771
- return mKind.Package;
1772
- case SymbolKind.Class:
1773
- return mKind.Class;
1774
- case SymbolKind.Method:
1775
- return mKind.Method;
1776
- case SymbolKind.Property:
1777
- return mKind.Property;
1778
- case SymbolKind.Field:
1779
- return mKind.Field;
1780
- case SymbolKind.Constructor:
1781
- return mKind.Constructor;
1782
- case SymbolKind.Enum:
1783
- return mKind.Enum;
1784
- case SymbolKind.Interface:
1785
- return mKind.Interface;
1786
- case SymbolKind.Function:
1787
- return mKind.Function;
1788
- case SymbolKind.Variable:
1789
- return mKind.Variable;
1790
- case SymbolKind.Constant:
1791
- return mKind.Constant;
1792
- case SymbolKind.String:
1793
- return mKind.String;
1794
- case SymbolKind.Number:
1795
- return mKind.Number;
1796
- case SymbolKind.Boolean:
1797
- return mKind.Boolean;
1798
- case SymbolKind.Array:
1799
- return mKind.Array;
1800
- }
1801
- return mKind.Function;
1802
- }
1803
- var DocumentLinkAdapter = class {
1804
- constructor(_worker) {
1805
- this._worker = _worker;
1806
- }
1807
- provideLinks(model, token) {
1808
- const resource = model.uri;
1809
- return this._worker(resource).then((worker) => worker.findDocumentLinks(resource.toString())).then((items) => {
1810
- if (!items) {
1811
- return;
1812
- }
1813
- return {
1814
- links: items.map((item) => ({
1815
- range: toRange(item.range),
1816
- url: item.target
1817
- }))
1818
- };
1819
- });
1820
- }
1821
- };
1822
- var DocumentFormattingEditProvider = class {
1823
- constructor(_worker) {
1824
- this._worker = _worker;
1825
- }
1826
- provideDocumentFormattingEdits(model, options, token) {
1827
- const resource = model.uri;
1828
- return this._worker(resource).then((worker) => {
1829
- return worker.format(resource.toString(), null, fromFormattingOptions(options)).then((edits) => {
1830
- if (!edits || edits.length === 0) {
1831
- return;
1832
- }
1833
- return edits.map(toTextEdit);
1834
- });
1835
- });
1836
- }
1837
- };
1838
- var DocumentRangeFormattingEditProvider = class {
1839
- constructor(_worker) {
1840
- this._worker = _worker;
1841
- }
1842
- canFormatMultipleRanges = false;
1843
- provideDocumentRangeFormattingEdits(model, range, options, token) {
1844
- const resource = model.uri;
1845
- return this._worker(resource).then((worker) => {
1846
- return worker.format(resource.toString(), fromRange(range), fromFormattingOptions(options)).then((edits) => {
1847
- if (!edits || edits.length === 0) {
1848
- return;
1849
- }
1850
- return edits.map(toTextEdit);
1851
- });
1852
- });
1853
- }
1854
- };
1855
- function fromFormattingOptions(options) {
1856
- return {
1857
- tabSize: options.tabSize,
1858
- insertSpaces: options.insertSpaces
1859
- };
1860
- }
1861
- var DocumentColorAdapter = class {
1862
- constructor(_worker) {
1863
- this._worker = _worker;
1864
- }
1865
- provideDocumentColors(model, token) {
1866
- const resource = model.uri;
1867
- return this._worker(resource).then((worker) => worker.findDocumentColors(resource.toString())).then((infos) => {
1868
- if (!infos) {
1869
- return;
1870
- }
1871
- return infos.map((item) => ({
1872
- color: item.color,
1873
- range: toRange(item.range)
1874
- }));
1875
- });
1876
- }
1877
- provideColorPresentations(model, info, token) {
1878
- const resource = model.uri;
1879
- return this._worker(resource).then((worker) => worker.getColorPresentations(resource.toString(), info.color, fromRange(info.range))).then((presentations) => {
1880
- if (!presentations) {
1881
- return;
1882
- }
1883
- return presentations.map((presentation) => {
1884
- let item = {
1885
- label: presentation.label
1886
- };
1887
- if (presentation.textEdit) {
1888
- item.textEdit = toTextEdit(presentation.textEdit);
1889
- }
1890
- if (presentation.additionalTextEdits) {
1891
- item.additionalTextEdits = presentation.additionalTextEdits.map(toTextEdit);
1892
- }
1893
- return item;
1894
- });
1895
- });
1896
- }
1897
- };
1898
- var FoldingRangeAdapter = class {
1899
- constructor(_worker) {
1900
- this._worker = _worker;
1901
- }
1902
- provideFoldingRanges(model, context, token) {
1903
- const resource = model.uri;
1904
- return this._worker(resource).then((worker) => worker.getFoldingRanges(resource.toString(), context)).then((ranges) => {
1905
- if (!ranges) {
1906
- return;
1907
- }
1908
- return ranges.map((range) => {
1909
- const result = {
1910
- start: range.startLine + 1,
1911
- end: range.endLine + 1
1912
- };
1913
- if (typeof range.kind !== "undefined") {
1914
- result.kind = toFoldingRangeKind(range.kind);
1915
- }
1916
- return result;
1917
- });
1918
- });
1919
- }
1920
- };
1921
- function toFoldingRangeKind(kind) {
1922
- switch (kind) {
1923
- case FoldingRangeKind.Comment:
1924
- return monaco_editor_core_exports.languages.FoldingRangeKind.Comment;
1925
- case FoldingRangeKind.Imports:
1926
- return monaco_editor_core_exports.languages.FoldingRangeKind.Imports;
1927
- case FoldingRangeKind.Region:
1928
- return monaco_editor_core_exports.languages.FoldingRangeKind.Region;
1929
- }
1930
- return void 0;
1931
- }
1932
- var SelectionRangeAdapter = class {
1933
- constructor(_worker) {
1934
- this._worker = _worker;
1935
- }
1936
- provideSelectionRanges(model, positions, token) {
1937
- const resource = model.uri;
1938
- return this._worker(resource).then((worker) => worker.getSelectionRanges(resource.toString(), positions.map(fromPosition))).then((selectionRanges) => {
1939
- if (!selectionRanges) {
1940
- return;
1941
- }
1942
- return selectionRanges.map((selectionRange) => {
1943
- const result = [];
1944
- while (selectionRange) {
1945
- result.push({ range: toRange(selectionRange.range) });
1946
- selectionRange = selectionRange.parent;
1947
- }
1948
- return result;
1949
- });
1950
- });
1951
- }
1952
- };
1953
-
1954
- // src/language/css/cssMode.ts
1955
- function setupMode(defaults) {
1956
- const disposables = [];
1957
- const providers = [];
1958
- const client = new WorkerManager(defaults);
1959
- disposables.push(client);
1960
- const worker = (...uris) => {
1961
- return client.getLanguageServiceWorker(...uris);
1962
- };
1963
- function registerProviders() {
1964
- const { languageId, modeConfiguration } = defaults;
1965
- disposeAll(providers);
1966
- if (modeConfiguration.completionItems) {
1967
- providers.push(monaco_editor_core_exports.languages.registerCompletionItemProvider(languageId, new CompletionAdapter(worker, ["/", "-", ":"])));
1968
- }
1969
- if (modeConfiguration.hovers) {
1970
- providers.push(monaco_editor_core_exports.languages.registerHoverProvider(languageId, new HoverAdapter(worker)));
1971
- }
1972
- if (modeConfiguration.documentHighlights) {
1973
- providers.push(monaco_editor_core_exports.languages.registerDocumentHighlightProvider(languageId, new DocumentHighlightAdapter(worker)));
1974
- }
1975
- if (modeConfiguration.definitions) {
1976
- providers.push(monaco_editor_core_exports.languages.registerDefinitionProvider(languageId, new DefinitionAdapter(worker)));
1977
- }
1978
- if (modeConfiguration.references) {
1979
- providers.push(monaco_editor_core_exports.languages.registerReferenceProvider(languageId, new ReferenceAdapter(worker)));
1980
- }
1981
- if (modeConfiguration.documentSymbols) {
1982
- providers.push(monaco_editor_core_exports.languages.registerDocumentSymbolProvider(languageId, new DocumentSymbolAdapter(worker)));
1983
- }
1984
- if (modeConfiguration.rename) {
1985
- providers.push(monaco_editor_core_exports.languages.registerRenameProvider(languageId, new RenameAdapter(worker)));
1986
- }
1987
- if (modeConfiguration.colors) {
1988
- providers.push(monaco_editor_core_exports.languages.registerColorProvider(languageId, new DocumentColorAdapter(worker)));
1989
- }
1990
- if (modeConfiguration.foldingRanges) {
1991
- providers.push(monaco_editor_core_exports.languages.registerFoldingRangeProvider(languageId, new FoldingRangeAdapter(worker)));
1992
- }
1993
- if (modeConfiguration.diagnostics) {
1994
- providers.push(new DiagnosticsAdapter(languageId, worker, defaults.onDidChange));
1995
- }
1996
- if (modeConfiguration.selectionRanges) {
1997
- providers.push(monaco_editor_core_exports.languages.registerSelectionRangeProvider(languageId, new SelectionRangeAdapter(worker)));
1998
- }
1999
- if (modeConfiguration.documentFormattingEdits) {
2000
- providers.push(monaco_editor_core_exports.languages.registerDocumentFormattingEditProvider(languageId, new DocumentFormattingEditProvider(worker)));
2001
- }
2002
- if (modeConfiguration.documentRangeFormattingEdits) {
2003
- providers.push(monaco_editor_core_exports.languages.registerDocumentRangeFormattingEditProvider(languageId, new DocumentRangeFormattingEditProvider(worker)));
2004
- }
2005
- }
2006
- registerProviders();
2007
- disposables.push(asDisposable(providers));
2008
- return asDisposable(disposables);
2009
- }
2010
- function asDisposable(disposables) {
2011
- return { dispose: () => disposeAll(disposables) };
2012
- }
2013
- function disposeAll(disposables) {
2014
- while (disposables.length) {
2015
- disposables.pop().dispose();
2016
- }
2017
- }
2018
-
2019
- exports.CompletionAdapter = CompletionAdapter;
2020
- exports.DefinitionAdapter = DefinitionAdapter;
2021
- exports.DiagnosticsAdapter = DiagnosticsAdapter;
2022
- exports.DocumentColorAdapter = DocumentColorAdapter;
2023
- exports.DocumentFormattingEditProvider = DocumentFormattingEditProvider;
2024
- exports.DocumentHighlightAdapter = DocumentHighlightAdapter;
2025
- exports.DocumentLinkAdapter = DocumentLinkAdapter;
2026
- exports.DocumentRangeFormattingEditProvider = DocumentRangeFormattingEditProvider;
2027
- exports.DocumentSymbolAdapter = DocumentSymbolAdapter;
2028
- exports.FoldingRangeAdapter = FoldingRangeAdapter;
2029
- exports.HoverAdapter = HoverAdapter;
2030
- exports.ReferenceAdapter = ReferenceAdapter;
2031
- exports.RenameAdapter = RenameAdapter;
2032
- exports.SelectionRangeAdapter = SelectionRangeAdapter;
2033
- exports.WorkerManager = WorkerManager;
2034
- exports.fromPosition = fromPosition;
2035
- exports.fromRange = fromRange;
2036
- exports.setupMode = setupMode;
2037
- exports.toRange = toRange;
2038
- exports.toTextEdit = toTextEdit;