@arcgis/coding-components 1.0.0-beta.10 → 1.0.0-beta.11

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,2114 +0,0 @@
1
- import { e as editor, M as MarkerSeverity, v as DiagnosticSeverity$1, R as Range$1, w as InsertTextFormat$1, l as languages, C as CompletionItemKind$1, E as Emitter } from './arcade-defaults-24670a1d.js';
2
- import './index-d4ec142a.js';
3
-
4
- // src/services/api-context.ts
5
-
6
- // ../arcade-parser/dist/esm/index.js
7
- var Literals = /* @__PURE__ */ ((Literals2) => {
8
- Literals2["False"] = "false";
9
- Literals2["Null"] = "null";
10
- Literals2["True"] = "true";
11
- return Literals2;
12
- })(Literals || {});
13
- var Keywords = /* @__PURE__ */ ((Keywords2) => {
14
- Keywords2["Break"] = "break";
15
- Keywords2["Continue"] = "continue";
16
- Keywords2["Else"] = "else";
17
- Keywords2["For"] = "for";
18
- Keywords2["From"] = "from";
19
- Keywords2["Function"] = "function";
20
- Keywords2["If"] = "if";
21
- Keywords2["Import"] = "import";
22
- Keywords2["Export"] = "export";
23
- Keywords2["In"] = "in";
24
- Keywords2["Return"] = "return";
25
- Keywords2["Var"] = "var";
26
- Keywords2["While"] = "while";
27
- return Keywords2;
28
- })(Keywords || {});
29
- var UpdateOperators = ["++", "--"];
30
- var UnaryOperators = ["-", "+", "!", "~"];
31
- var AssignmentOperators = ["=", "/=", "*=", "%=", "+=", "-="];
32
- var LogicalOperators = ["||", "&&"];
33
- var BinaryOperators = [
34
- "|",
35
- "&",
36
- ">>",
37
- "<<",
38
- ">>>",
39
- "^",
40
- "==",
41
- "!=",
42
- "<",
43
- "<=",
44
- ">",
45
- ">=",
46
- "+",
47
- "-",
48
- "*",
49
- "/",
50
- "%"
51
- ];
52
- var OperatorsByLength = [[], [], []];
53
- UpdateOperators.forEach((op) => OperatorsByLength[op.length - 1].push(op));
54
- UnaryOperators.forEach((op) => OperatorsByLength[op.length - 1].push(op));
55
- LogicalOperators.forEach((op) => OperatorsByLength[op.length - 1].push(op));
56
- AssignmentOperators.forEach((op) => OperatorsByLength[op.length - 1].push(op));
57
- BinaryOperators.forEach((op) => OperatorsByLength[op.length - 1].push(op));
58
-
59
- // ../../../node_modules/vscode-languageserver-types/lib/esm/main.js
60
- var DocumentUri;
61
- (function(DocumentUri2) {
62
- function is(value) {
63
- return typeof value === "string";
64
- }
65
- DocumentUri2.is = is;
66
- })(DocumentUri || (DocumentUri = {}));
67
- var URI;
68
- (function(URI2) {
69
- function is(value) {
70
- return typeof value === "string";
71
- }
72
- URI2.is = is;
73
- })(URI || (URI = {}));
74
- var integer;
75
- (function(integer2) {
76
- integer2.MIN_VALUE = -2147483648;
77
- integer2.MAX_VALUE = 2147483647;
78
- function is(value) {
79
- return typeof value === "number" && integer2.MIN_VALUE <= value && value <= integer2.MAX_VALUE;
80
- }
81
- integer2.is = is;
82
- })(integer || (integer = {}));
83
- var uinteger;
84
- (function(uinteger2) {
85
- uinteger2.MIN_VALUE = 0;
86
- uinteger2.MAX_VALUE = 2147483647;
87
- function is(value) {
88
- return typeof value === "number" && uinteger2.MIN_VALUE <= value && value <= uinteger2.MAX_VALUE;
89
- }
90
- uinteger2.is = is;
91
- })(uinteger || (uinteger = {}));
92
- var Position;
93
- (function(Position4) {
94
- function create(line, character) {
95
- if (line === Number.MAX_VALUE) {
96
- line = uinteger.MAX_VALUE;
97
- }
98
- if (character === Number.MAX_VALUE) {
99
- character = uinteger.MAX_VALUE;
100
- }
101
- return { line, character };
102
- }
103
- Position4.create = create;
104
- function is(value) {
105
- var candidate = value;
106
- return Is.objectLiteral(candidate) && Is.uinteger(candidate.line) && Is.uinteger(candidate.character);
107
- }
108
- Position4.is = is;
109
- })(Position || (Position = {}));
110
- var Range;
111
- (function(Range3) {
112
- function create(one, two, three, four) {
113
- if (Is.uinteger(one) && Is.uinteger(two) && Is.uinteger(three) && Is.uinteger(four)) {
114
- return { start: Position.create(one, two), end: Position.create(three, four) };
115
- } else if (Position.is(one) && Position.is(two)) {
116
- return { start: one, end: two };
117
- } else {
118
- throw new Error("Range#create called with invalid arguments[".concat(one, ", ").concat(two, ", ").concat(three, ", ").concat(four, "]"));
119
- }
120
- }
121
- Range3.create = create;
122
- function is(value) {
123
- var candidate = value;
124
- return Is.objectLiteral(candidate) && Position.is(candidate.start) && Position.is(candidate.end);
125
- }
126
- Range3.is = is;
127
- })(Range || (Range = {}));
128
- var Location;
129
- (function(Location2) {
130
- function create(uri, range) {
131
- return { uri, range };
132
- }
133
- Location2.create = create;
134
- function is(value) {
135
- var candidate = value;
136
- return Is.objectLiteral(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
137
- }
138
- Location2.is = is;
139
- })(Location || (Location = {}));
140
- var LocationLink;
141
- (function(LocationLink2) {
142
- function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) {
143
- return { targetUri, targetRange, targetSelectionRange, originSelectionRange };
144
- }
145
- LocationLink2.create = create;
146
- function is(value) {
147
- var candidate = value;
148
- return Is.objectLiteral(candidate) && Range.is(candidate.targetRange) && Is.string(candidate.targetUri) && Range.is(candidate.targetSelectionRange) && (Range.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));
149
- }
150
- LocationLink2.is = is;
151
- })(LocationLink || (LocationLink = {}));
152
- var Color;
153
- (function(Color2) {
154
- function create(red, green, blue, alpha) {
155
- return {
156
- red,
157
- green,
158
- blue,
159
- alpha
160
- };
161
- }
162
- Color2.create = create;
163
- function is(value) {
164
- var candidate = value;
165
- return Is.objectLiteral(candidate) && Is.numberRange(candidate.red, 0, 1) && Is.numberRange(candidate.green, 0, 1) && Is.numberRange(candidate.blue, 0, 1) && Is.numberRange(candidate.alpha, 0, 1);
166
- }
167
- Color2.is = is;
168
- })(Color || (Color = {}));
169
- var ColorInformation;
170
- (function(ColorInformation2) {
171
- function create(range, color) {
172
- return {
173
- range,
174
- color
175
- };
176
- }
177
- ColorInformation2.create = create;
178
- function is(value) {
179
- var candidate = value;
180
- return Is.objectLiteral(candidate) && Range.is(candidate.range) && Color.is(candidate.color);
181
- }
182
- ColorInformation2.is = is;
183
- })(ColorInformation || (ColorInformation = {}));
184
- var ColorPresentation;
185
- (function(ColorPresentation2) {
186
- function create(label, textEdit, additionalTextEdits) {
187
- return {
188
- label,
189
- textEdit,
190
- additionalTextEdits
191
- };
192
- }
193
- ColorPresentation2.create = create;
194
- function is(value) {
195
- var candidate = value;
196
- return Is.objectLiteral(candidate) && Is.string(candidate.label) && (Is.undefined(candidate.textEdit) || TextEdit.is(candidate)) && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit.is));
197
- }
198
- ColorPresentation2.is = is;
199
- })(ColorPresentation || (ColorPresentation = {}));
200
- var FoldingRangeKind;
201
- (function(FoldingRangeKind2) {
202
- FoldingRangeKind2.Comment = "comment";
203
- FoldingRangeKind2.Imports = "imports";
204
- FoldingRangeKind2.Region = "region";
205
- })(FoldingRangeKind || (FoldingRangeKind = {}));
206
- var FoldingRange;
207
- (function(FoldingRange2) {
208
- function create(startLine, endLine, startCharacter, endCharacter, kind, collapsedText) {
209
- var result = {
210
- startLine,
211
- endLine
212
- };
213
- if (Is.defined(startCharacter)) {
214
- result.startCharacter = startCharacter;
215
- }
216
- if (Is.defined(endCharacter)) {
217
- result.endCharacter = endCharacter;
218
- }
219
- if (Is.defined(kind)) {
220
- result.kind = kind;
221
- }
222
- if (Is.defined(collapsedText)) {
223
- result.collapsedText = collapsedText;
224
- }
225
- return result;
226
- }
227
- FoldingRange2.create = create;
228
- function is(value) {
229
- var candidate = value;
230
- return Is.objectLiteral(candidate) && 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));
231
- }
232
- FoldingRange2.is = is;
233
- })(FoldingRange || (FoldingRange = {}));
234
- var DiagnosticRelatedInformation;
235
- (function(DiagnosticRelatedInformation2) {
236
- function create(location, message) {
237
- return {
238
- location,
239
- message
240
- };
241
- }
242
- DiagnosticRelatedInformation2.create = create;
243
- function is(value) {
244
- var candidate = value;
245
- return Is.defined(candidate) && Location.is(candidate.location) && Is.string(candidate.message);
246
- }
247
- DiagnosticRelatedInformation2.is = is;
248
- })(DiagnosticRelatedInformation || (DiagnosticRelatedInformation = {}));
249
- var DiagnosticSeverity;
250
- (function(DiagnosticSeverity2) {
251
- DiagnosticSeverity2.Error = 1;
252
- DiagnosticSeverity2.Warning = 2;
253
- DiagnosticSeverity2.Information = 3;
254
- DiagnosticSeverity2.Hint = 4;
255
- })(DiagnosticSeverity || (DiagnosticSeverity = {}));
256
- var DiagnosticTag;
257
- (function(DiagnosticTag2) {
258
- DiagnosticTag2.Unnecessary = 1;
259
- DiagnosticTag2.Deprecated = 2;
260
- })(DiagnosticTag || (DiagnosticTag = {}));
261
- var CodeDescription;
262
- (function(CodeDescription2) {
263
- function is(value) {
264
- var candidate = value;
265
- return Is.objectLiteral(candidate) && Is.string(candidate.href);
266
- }
267
- CodeDescription2.is = is;
268
- })(CodeDescription || (CodeDescription = {}));
269
- var Diagnostic2;
270
- (function(Diagnostic4) {
271
- function create(range, message, severity, code, source, relatedInformation) {
272
- var result = { range, message };
273
- if (Is.defined(severity)) {
274
- result.severity = severity;
275
- }
276
- if (Is.defined(code)) {
277
- result.code = code;
278
- }
279
- if (Is.defined(source)) {
280
- result.source = source;
281
- }
282
- if (Is.defined(relatedInformation)) {
283
- result.relatedInformation = relatedInformation;
284
- }
285
- return result;
286
- }
287
- Diagnostic4.create = create;
288
- function is(value) {
289
- var _a;
290
- var candidate = value;
291
- 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));
292
- }
293
- Diagnostic4.is = is;
294
- })(Diagnostic2 || (Diagnostic2 = {}));
295
- var Command;
296
- (function(Command2) {
297
- function create(title, command) {
298
- var args = [];
299
- for (var _i = 2; _i < arguments.length; _i++) {
300
- args[_i - 2] = arguments[_i];
301
- }
302
- var result = { title, command };
303
- if (Is.defined(args) && args.length > 0) {
304
- result.arguments = args;
305
- }
306
- return result;
307
- }
308
- Command2.create = create;
309
- function is(value) {
310
- var candidate = value;
311
- return Is.defined(candidate) && Is.string(candidate.title) && Is.string(candidate.command);
312
- }
313
- Command2.is = is;
314
- })(Command || (Command = {}));
315
- var TextEdit;
316
- (function(TextEdit2) {
317
- function replace(range, newText) {
318
- return { range, newText };
319
- }
320
- TextEdit2.replace = replace;
321
- function insert(position, newText) {
322
- return { range: { start: position, end: position }, newText };
323
- }
324
- TextEdit2.insert = insert;
325
- function del(range) {
326
- return { range, newText: "" };
327
- }
328
- TextEdit2.del = del;
329
- function is(value) {
330
- var candidate = value;
331
- return Is.objectLiteral(candidate) && Is.string(candidate.newText) && Range.is(candidate.range);
332
- }
333
- TextEdit2.is = is;
334
- })(TextEdit || (TextEdit = {}));
335
- var ChangeAnnotation;
336
- (function(ChangeAnnotation2) {
337
- function create(label, needsConfirmation, description) {
338
- var result = { label };
339
- if (needsConfirmation !== void 0) {
340
- result.needsConfirmation = needsConfirmation;
341
- }
342
- if (description !== void 0) {
343
- result.description = description;
344
- }
345
- return result;
346
- }
347
- ChangeAnnotation2.create = create;
348
- function is(value) {
349
- var candidate = value;
350
- return Is.objectLiteral(candidate) && Is.string(candidate.label) && (Is.boolean(candidate.needsConfirmation) || candidate.needsConfirmation === void 0) && (Is.string(candidate.description) || candidate.description === void 0);
351
- }
352
- ChangeAnnotation2.is = is;
353
- })(ChangeAnnotation || (ChangeAnnotation = {}));
354
- var ChangeAnnotationIdentifier;
355
- (function(ChangeAnnotationIdentifier2) {
356
- function is(value) {
357
- var candidate = value;
358
- return Is.string(candidate);
359
- }
360
- ChangeAnnotationIdentifier2.is = is;
361
- })(ChangeAnnotationIdentifier || (ChangeAnnotationIdentifier = {}));
362
- var AnnotatedTextEdit;
363
- (function(AnnotatedTextEdit2) {
364
- function replace(range, newText, annotation) {
365
- return { range, newText, annotationId: annotation };
366
- }
367
- AnnotatedTextEdit2.replace = replace;
368
- function insert(position, newText, annotation) {
369
- return { range: { start: position, end: position }, newText, annotationId: annotation };
370
- }
371
- AnnotatedTextEdit2.insert = insert;
372
- function del(range, annotation) {
373
- return { range, newText: "", annotationId: annotation };
374
- }
375
- AnnotatedTextEdit2.del = del;
376
- function is(value) {
377
- var candidate = value;
378
- return TextEdit.is(candidate) && (ChangeAnnotation.is(candidate.annotationId) || ChangeAnnotationIdentifier.is(candidate.annotationId));
379
- }
380
- AnnotatedTextEdit2.is = is;
381
- })(AnnotatedTextEdit || (AnnotatedTextEdit = {}));
382
- var TextDocumentEdit;
383
- (function(TextDocumentEdit2) {
384
- function create(textDocument, edits) {
385
- return { textDocument, edits };
386
- }
387
- TextDocumentEdit2.create = create;
388
- function is(value) {
389
- var candidate = value;
390
- return Is.defined(candidate) && OptionalVersionedTextDocumentIdentifier.is(candidate.textDocument) && Array.isArray(candidate.edits);
391
- }
392
- TextDocumentEdit2.is = is;
393
- })(TextDocumentEdit || (TextDocumentEdit = {}));
394
- var CreateFile;
395
- (function(CreateFile2) {
396
- function create(uri, options, annotation) {
397
- var result = {
398
- kind: "create",
399
- uri
400
- };
401
- if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
402
- result.options = options;
403
- }
404
- if (annotation !== void 0) {
405
- result.annotationId = annotation;
406
- }
407
- return result;
408
- }
409
- CreateFile2.create = create;
410
- function is(value) {
411
- var candidate = value;
412
- 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));
413
- }
414
- CreateFile2.is = is;
415
- })(CreateFile || (CreateFile = {}));
416
- var RenameFile;
417
- (function(RenameFile2) {
418
- function create(oldUri, newUri, options, annotation) {
419
- var result = {
420
- kind: "rename",
421
- oldUri,
422
- newUri
423
- };
424
- if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
425
- result.options = options;
426
- }
427
- if (annotation !== void 0) {
428
- result.annotationId = annotation;
429
- }
430
- return result;
431
- }
432
- RenameFile2.create = create;
433
- function is(value) {
434
- var candidate = value;
435
- 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));
436
- }
437
- RenameFile2.is = is;
438
- })(RenameFile || (RenameFile = {}));
439
- var DeleteFile;
440
- (function(DeleteFile2) {
441
- function create(uri, options, annotation) {
442
- var result = {
443
- kind: "delete",
444
- uri
445
- };
446
- if (options !== void 0 && (options.recursive !== void 0 || options.ignoreIfNotExists !== void 0)) {
447
- result.options = options;
448
- }
449
- if (annotation !== void 0) {
450
- result.annotationId = annotation;
451
- }
452
- return result;
453
- }
454
- DeleteFile2.create = create;
455
- function is(value) {
456
- var candidate = value;
457
- 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));
458
- }
459
- DeleteFile2.is = is;
460
- })(DeleteFile || (DeleteFile = {}));
461
- var WorkspaceEdit;
462
- (function(WorkspaceEdit2) {
463
- function is(value) {
464
- var candidate = value;
465
- return candidate && (candidate.changes !== void 0 || candidate.documentChanges !== void 0) && (candidate.documentChanges === void 0 || candidate.documentChanges.every(function(change) {
466
- if (Is.string(change.kind)) {
467
- return CreateFile.is(change) || RenameFile.is(change) || DeleteFile.is(change);
468
- } else {
469
- return TextDocumentEdit.is(change);
470
- }
471
- }));
472
- }
473
- WorkspaceEdit2.is = is;
474
- })(WorkspaceEdit || (WorkspaceEdit = {}));
475
- var TextEditChangeImpl = (
476
- /** @class */
477
- function() {
478
- function TextEditChangeImpl2(edits, changeAnnotations) {
479
- this.edits = edits;
480
- this.changeAnnotations = changeAnnotations;
481
- }
482
- TextEditChangeImpl2.prototype.insert = function(position, newText, annotation) {
483
- var edit;
484
- var id;
485
- if (annotation === void 0) {
486
- edit = TextEdit.insert(position, newText);
487
- } else if (ChangeAnnotationIdentifier.is(annotation)) {
488
- id = annotation;
489
- edit = AnnotatedTextEdit.insert(position, newText, annotation);
490
- } else {
491
- this.assertChangeAnnotations(this.changeAnnotations);
492
- id = this.changeAnnotations.manage(annotation);
493
- edit = AnnotatedTextEdit.insert(position, newText, id);
494
- }
495
- this.edits.push(edit);
496
- if (id !== void 0) {
497
- return id;
498
- }
499
- };
500
- TextEditChangeImpl2.prototype.replace = function(range, newText, annotation) {
501
- var edit;
502
- var id;
503
- if (annotation === void 0) {
504
- edit = TextEdit.replace(range, newText);
505
- } else if (ChangeAnnotationIdentifier.is(annotation)) {
506
- id = annotation;
507
- edit = AnnotatedTextEdit.replace(range, newText, annotation);
508
- } else {
509
- this.assertChangeAnnotations(this.changeAnnotations);
510
- id = this.changeAnnotations.manage(annotation);
511
- edit = AnnotatedTextEdit.replace(range, newText, id);
512
- }
513
- this.edits.push(edit);
514
- if (id !== void 0) {
515
- return id;
516
- }
517
- };
518
- TextEditChangeImpl2.prototype.delete = function(range, annotation) {
519
- var edit;
520
- var id;
521
- if (annotation === void 0) {
522
- edit = TextEdit.del(range);
523
- } else if (ChangeAnnotationIdentifier.is(annotation)) {
524
- id = annotation;
525
- edit = AnnotatedTextEdit.del(range, annotation);
526
- } else {
527
- this.assertChangeAnnotations(this.changeAnnotations);
528
- id = this.changeAnnotations.manage(annotation);
529
- edit = AnnotatedTextEdit.del(range, id);
530
- }
531
- this.edits.push(edit);
532
- if (id !== void 0) {
533
- return id;
534
- }
535
- };
536
- TextEditChangeImpl2.prototype.add = function(edit) {
537
- this.edits.push(edit);
538
- };
539
- TextEditChangeImpl2.prototype.all = function() {
540
- return this.edits;
541
- };
542
- TextEditChangeImpl2.prototype.clear = function() {
543
- this.edits.splice(0, this.edits.length);
544
- };
545
- TextEditChangeImpl2.prototype.assertChangeAnnotations = function(value) {
546
- if (value === void 0) {
547
- throw new Error("Text edit change is not configured to manage change annotations.");
548
- }
549
- };
550
- return TextEditChangeImpl2;
551
- }()
552
- );
553
- var ChangeAnnotations = (
554
- /** @class */
555
- function() {
556
- function ChangeAnnotations2(annotations) {
557
- this._annotations = annotations === void 0 ? /* @__PURE__ */ Object.create(null) : annotations;
558
- this._counter = 0;
559
- this._size = 0;
560
- }
561
- ChangeAnnotations2.prototype.all = function() {
562
- return this._annotations;
563
- };
564
- Object.defineProperty(ChangeAnnotations2.prototype, "size", {
565
- get: function() {
566
- return this._size;
567
- },
568
- enumerable: false,
569
- configurable: true
570
- });
571
- ChangeAnnotations2.prototype.manage = function(idOrAnnotation, annotation) {
572
- var id;
573
- if (ChangeAnnotationIdentifier.is(idOrAnnotation)) {
574
- id = idOrAnnotation;
575
- } else {
576
- id = this.nextId();
577
- annotation = idOrAnnotation;
578
- }
579
- if (this._annotations[id] !== void 0) {
580
- throw new Error("Id ".concat(id, " is already in use."));
581
- }
582
- if (annotation === void 0) {
583
- throw new Error("No annotation provided for id ".concat(id));
584
- }
585
- this._annotations[id] = annotation;
586
- this._size++;
587
- return id;
588
- };
589
- ChangeAnnotations2.prototype.nextId = function() {
590
- this._counter++;
591
- return this._counter.toString();
592
- };
593
- return ChangeAnnotations2;
594
- }()
595
- );
596
- (
597
- /** @class */
598
- (function() {
599
- function WorkspaceChange2(workspaceEdit) {
600
- var _this = this;
601
- this._textEditChanges = /* @__PURE__ */ Object.create(null);
602
- if (workspaceEdit !== void 0) {
603
- this._workspaceEdit = workspaceEdit;
604
- if (workspaceEdit.documentChanges) {
605
- this._changeAnnotations = new ChangeAnnotations(workspaceEdit.changeAnnotations);
606
- workspaceEdit.changeAnnotations = this._changeAnnotations.all();
607
- workspaceEdit.documentChanges.forEach(function(change) {
608
- if (TextDocumentEdit.is(change)) {
609
- var textEditChange = new TextEditChangeImpl(change.edits, _this._changeAnnotations);
610
- _this._textEditChanges[change.textDocument.uri] = textEditChange;
611
- }
612
- });
613
- } else if (workspaceEdit.changes) {
614
- Object.keys(workspaceEdit.changes).forEach(function(key) {
615
- var textEditChange = new TextEditChangeImpl(workspaceEdit.changes[key]);
616
- _this._textEditChanges[key] = textEditChange;
617
- });
618
- }
619
- } else {
620
- this._workspaceEdit = {};
621
- }
622
- }
623
- Object.defineProperty(WorkspaceChange2.prototype, "edit", {
624
- /**
625
- * Returns the underlying {@link WorkspaceEdit} literal
626
- * use to be returned from a workspace edit operation like rename.
627
- */
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
- );
763
- var TextDocumentIdentifier;
764
- (function(TextDocumentIdentifier2) {
765
- function create(uri) {
766
- return { uri };
767
- }
768
- TextDocumentIdentifier2.create = create;
769
- function is(value) {
770
- var candidate = value;
771
- return Is.defined(candidate) && Is.string(candidate.uri);
772
- }
773
- TextDocumentIdentifier2.is = is;
774
- })(TextDocumentIdentifier || (TextDocumentIdentifier = {}));
775
- var VersionedTextDocumentIdentifier;
776
- (function(VersionedTextDocumentIdentifier2) {
777
- function create(uri, version) {
778
- return { uri, version };
779
- }
780
- VersionedTextDocumentIdentifier2.create = create;
781
- function is(value) {
782
- var candidate = value;
783
- return Is.defined(candidate) && Is.string(candidate.uri) && Is.integer(candidate.version);
784
- }
785
- VersionedTextDocumentIdentifier2.is = is;
786
- })(VersionedTextDocumentIdentifier || (VersionedTextDocumentIdentifier = {}));
787
- var OptionalVersionedTextDocumentIdentifier;
788
- (function(OptionalVersionedTextDocumentIdentifier2) {
789
- function create(uri, version) {
790
- return { uri, version };
791
- }
792
- OptionalVersionedTextDocumentIdentifier2.create = create;
793
- function is(value) {
794
- var candidate = value;
795
- return Is.defined(candidate) && Is.string(candidate.uri) && (candidate.version === null || Is.integer(candidate.version));
796
- }
797
- OptionalVersionedTextDocumentIdentifier2.is = is;
798
- })(OptionalVersionedTextDocumentIdentifier || (OptionalVersionedTextDocumentIdentifier = {}));
799
- var TextDocumentItem;
800
- (function(TextDocumentItem2) {
801
- function create(uri, languageId, version, text) {
802
- return { uri, languageId, version, text };
803
- }
804
- TextDocumentItem2.create = create;
805
- function is(value) {
806
- var candidate = value;
807
- return Is.defined(candidate) && Is.string(candidate.uri) && Is.string(candidate.languageId) && Is.integer(candidate.version) && Is.string(candidate.text);
808
- }
809
- TextDocumentItem2.is = is;
810
- })(TextDocumentItem || (TextDocumentItem = {}));
811
- var MarkupKind;
812
- (function(MarkupKind2) {
813
- MarkupKind2.PlainText = "plaintext";
814
- MarkupKind2.Markdown = "markdown";
815
- function is(value) {
816
- var candidate = value;
817
- return candidate === MarkupKind2.PlainText || candidate === MarkupKind2.Markdown;
818
- }
819
- MarkupKind2.is = is;
820
- })(MarkupKind || (MarkupKind = {}));
821
- var MarkupContent;
822
- (function(MarkupContent2) {
823
- function is(value) {
824
- var candidate = value;
825
- return Is.objectLiteral(value) && MarkupKind.is(candidate.kind) && Is.string(candidate.value);
826
- }
827
- MarkupContent2.is = is;
828
- })(MarkupContent || (MarkupContent = {}));
829
- var CompletionItemKind;
830
- (function(CompletionItemKind2) {
831
- CompletionItemKind2.Text = 1;
832
- CompletionItemKind2.Method = 2;
833
- CompletionItemKind2.Function = 3;
834
- CompletionItemKind2.Constructor = 4;
835
- CompletionItemKind2.Field = 5;
836
- CompletionItemKind2.Variable = 6;
837
- CompletionItemKind2.Class = 7;
838
- CompletionItemKind2.Interface = 8;
839
- CompletionItemKind2.Module = 9;
840
- CompletionItemKind2.Property = 10;
841
- CompletionItemKind2.Unit = 11;
842
- CompletionItemKind2.Value = 12;
843
- CompletionItemKind2.Enum = 13;
844
- CompletionItemKind2.Keyword = 14;
845
- CompletionItemKind2.Snippet = 15;
846
- CompletionItemKind2.Color = 16;
847
- CompletionItemKind2.File = 17;
848
- CompletionItemKind2.Reference = 18;
849
- CompletionItemKind2.Folder = 19;
850
- CompletionItemKind2.EnumMember = 20;
851
- CompletionItemKind2.Constant = 21;
852
- CompletionItemKind2.Struct = 22;
853
- CompletionItemKind2.Event = 23;
854
- CompletionItemKind2.Operator = 24;
855
- CompletionItemKind2.TypeParameter = 25;
856
- })(CompletionItemKind || (CompletionItemKind = {}));
857
- var InsertTextFormat;
858
- (function(InsertTextFormat2) {
859
- InsertTextFormat2.PlainText = 1;
860
- InsertTextFormat2.Snippet = 2;
861
- })(InsertTextFormat || (InsertTextFormat = {}));
862
- var CompletionItemTag;
863
- (function(CompletionItemTag2) {
864
- CompletionItemTag2.Deprecated = 1;
865
- })(CompletionItemTag || (CompletionItemTag = {}));
866
- var InsertReplaceEdit;
867
- (function(InsertReplaceEdit2) {
868
- function create(newText, insert, replace) {
869
- return { newText, insert, replace };
870
- }
871
- InsertReplaceEdit2.create = create;
872
- function is(value) {
873
- var candidate = value;
874
- return candidate && Is.string(candidate.newText) && Range.is(candidate.insert) && Range.is(candidate.replace);
875
- }
876
- InsertReplaceEdit2.is = is;
877
- })(InsertReplaceEdit || (InsertReplaceEdit = {}));
878
- var InsertTextMode;
879
- (function(InsertTextMode2) {
880
- InsertTextMode2.asIs = 1;
881
- InsertTextMode2.adjustIndentation = 2;
882
- })(InsertTextMode || (InsertTextMode = {}));
883
- var CompletionItemLabelDetails;
884
- (function(CompletionItemLabelDetails2) {
885
- function is(value) {
886
- var candidate = value;
887
- return candidate && (Is.string(candidate.detail) || candidate.detail === void 0) && (Is.string(candidate.description) || candidate.description === void 0);
888
- }
889
- CompletionItemLabelDetails2.is = is;
890
- })(CompletionItemLabelDetails || (CompletionItemLabelDetails = {}));
891
- var CompletionItem;
892
- (function(CompletionItem6) {
893
- function create(label) {
894
- return { label };
895
- }
896
- CompletionItem6.create = create;
897
- })(CompletionItem || (CompletionItem = {}));
898
- var CompletionList;
899
- (function(CompletionList3) {
900
- function create(items, isIncomplete) {
901
- return { items: items ? items : [], isIncomplete: !!isIncomplete };
902
- }
903
- CompletionList3.create = create;
904
- })(CompletionList || (CompletionList = {}));
905
- var MarkedString;
906
- (function(MarkedString2) {
907
- function fromPlainText(plainText) {
908
- return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&");
909
- }
910
- MarkedString2.fromPlainText = fromPlainText;
911
- function is(value) {
912
- var candidate = value;
913
- return Is.string(candidate) || Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value);
914
- }
915
- MarkedString2.is = is;
916
- })(MarkedString || (MarkedString = {}));
917
- var Hover;
918
- (function(Hover2) {
919
- function is(value) {
920
- var candidate = value;
921
- 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));
922
- }
923
- Hover2.is = is;
924
- })(Hover || (Hover = {}));
925
- var ParameterInformation;
926
- (function(ParameterInformation2) {
927
- function create(label, documentation) {
928
- return documentation ? { label, documentation } : { label };
929
- }
930
- ParameterInformation2.create = create;
931
- })(ParameterInformation || (ParameterInformation = {}));
932
- var SignatureInformation;
933
- (function(SignatureInformation2) {
934
- function create(label, documentation) {
935
- var parameters = [];
936
- for (var _i = 2; _i < arguments.length; _i++) {
937
- parameters[_i - 2] = arguments[_i];
938
- }
939
- var result = { label };
940
- if (Is.defined(documentation)) {
941
- result.documentation = documentation;
942
- }
943
- if (Is.defined(parameters)) {
944
- result.parameters = parameters;
945
- } else {
946
- result.parameters = [];
947
- }
948
- return result;
949
- }
950
- SignatureInformation2.create = create;
951
- })(SignatureInformation || (SignatureInformation = {}));
952
- var DocumentHighlightKind;
953
- (function(DocumentHighlightKind2) {
954
- DocumentHighlightKind2.Text = 1;
955
- DocumentHighlightKind2.Read = 2;
956
- DocumentHighlightKind2.Write = 3;
957
- })(DocumentHighlightKind || (DocumentHighlightKind = {}));
958
- var DocumentHighlight;
959
- (function(DocumentHighlight2) {
960
- function create(range, kind) {
961
- var result = { range };
962
- if (Is.number(kind)) {
963
- result.kind = kind;
964
- }
965
- return result;
966
- }
967
- DocumentHighlight2.create = create;
968
- })(DocumentHighlight || (DocumentHighlight = {}));
969
- var SymbolKind;
970
- (function(SymbolKind2) {
971
- SymbolKind2.File = 1;
972
- SymbolKind2.Module = 2;
973
- SymbolKind2.Namespace = 3;
974
- SymbolKind2.Package = 4;
975
- SymbolKind2.Class = 5;
976
- SymbolKind2.Method = 6;
977
- SymbolKind2.Property = 7;
978
- SymbolKind2.Field = 8;
979
- SymbolKind2.Constructor = 9;
980
- SymbolKind2.Enum = 10;
981
- SymbolKind2.Interface = 11;
982
- SymbolKind2.Function = 12;
983
- SymbolKind2.Variable = 13;
984
- SymbolKind2.Constant = 14;
985
- SymbolKind2.String = 15;
986
- SymbolKind2.Number = 16;
987
- SymbolKind2.Boolean = 17;
988
- SymbolKind2.Array = 18;
989
- SymbolKind2.Object = 19;
990
- SymbolKind2.Key = 20;
991
- SymbolKind2.Null = 21;
992
- SymbolKind2.EnumMember = 22;
993
- SymbolKind2.Struct = 23;
994
- SymbolKind2.Event = 24;
995
- SymbolKind2.Operator = 25;
996
- SymbolKind2.TypeParameter = 26;
997
- })(SymbolKind || (SymbolKind = {}));
998
- var SymbolTag;
999
- (function(SymbolTag2) {
1000
- SymbolTag2.Deprecated = 1;
1001
- })(SymbolTag || (SymbolTag = {}));
1002
- var SymbolInformation;
1003
- (function(SymbolInformation2) {
1004
- function create(name, kind, range, uri, containerName) {
1005
- var result = {
1006
- name,
1007
- kind,
1008
- location: { uri, range }
1009
- };
1010
- if (containerName) {
1011
- result.containerName = containerName;
1012
- }
1013
- return result;
1014
- }
1015
- SymbolInformation2.create = create;
1016
- })(SymbolInformation || (SymbolInformation = {}));
1017
- var WorkspaceSymbol;
1018
- (function(WorkspaceSymbol2) {
1019
- function create(name, kind, uri, range) {
1020
- return range !== void 0 ? { name, kind, location: { uri, range } } : { name, kind, location: { uri } };
1021
- }
1022
- WorkspaceSymbol2.create = create;
1023
- })(WorkspaceSymbol || (WorkspaceSymbol = {}));
1024
- var DocumentSymbol;
1025
- (function(DocumentSymbol2) {
1026
- function create(name, detail, kind, range, selectionRange, children) {
1027
- var result = {
1028
- name,
1029
- detail,
1030
- kind,
1031
- range,
1032
- selectionRange
1033
- };
1034
- if (children !== void 0) {
1035
- result.children = children;
1036
- }
1037
- return result;
1038
- }
1039
- DocumentSymbol2.create = create;
1040
- function is(value) {
1041
- var candidate = value;
1042
- 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));
1043
- }
1044
- DocumentSymbol2.is = is;
1045
- })(DocumentSymbol || (DocumentSymbol = {}));
1046
- var CodeActionKind;
1047
- (function(CodeActionKind2) {
1048
- CodeActionKind2.Empty = "";
1049
- CodeActionKind2.QuickFix = "quickfix";
1050
- CodeActionKind2.Refactor = "refactor";
1051
- CodeActionKind2.RefactorExtract = "refactor.extract";
1052
- CodeActionKind2.RefactorInline = "refactor.inline";
1053
- CodeActionKind2.RefactorRewrite = "refactor.rewrite";
1054
- CodeActionKind2.Source = "source";
1055
- CodeActionKind2.SourceOrganizeImports = "source.organizeImports";
1056
- CodeActionKind2.SourceFixAll = "source.fixAll";
1057
- })(CodeActionKind || (CodeActionKind = {}));
1058
- var CodeActionTriggerKind;
1059
- (function(CodeActionTriggerKind2) {
1060
- CodeActionTriggerKind2.Invoked = 1;
1061
- CodeActionTriggerKind2.Automatic = 2;
1062
- })(CodeActionTriggerKind || (CodeActionTriggerKind = {}));
1063
- var CodeActionContext;
1064
- (function(CodeActionContext2) {
1065
- function create(diagnostics, only, triggerKind) {
1066
- var result = { diagnostics };
1067
- if (only !== void 0 && only !== null) {
1068
- result.only = only;
1069
- }
1070
- if (triggerKind !== void 0 && triggerKind !== null) {
1071
- result.triggerKind = triggerKind;
1072
- }
1073
- return result;
1074
- }
1075
- CodeActionContext2.create = create;
1076
- function is(value) {
1077
- var candidate = value;
1078
- return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic2.is) && (candidate.only === void 0 || Is.typedArray(candidate.only, Is.string)) && (candidate.triggerKind === void 0 || candidate.triggerKind === CodeActionTriggerKind.Invoked || candidate.triggerKind === CodeActionTriggerKind.Automatic);
1079
- }
1080
- CodeActionContext2.is = is;
1081
- })(CodeActionContext || (CodeActionContext = {}));
1082
- var CodeAction;
1083
- (function(CodeAction2) {
1084
- function create(title, kindOrCommandOrEdit, kind) {
1085
- var result = { title };
1086
- var checkKind = true;
1087
- if (typeof kindOrCommandOrEdit === "string") {
1088
- checkKind = false;
1089
- result.kind = kindOrCommandOrEdit;
1090
- } else if (Command.is(kindOrCommandOrEdit)) {
1091
- result.command = kindOrCommandOrEdit;
1092
- } else {
1093
- result.edit = kindOrCommandOrEdit;
1094
- }
1095
- if (checkKind && kind !== void 0) {
1096
- result.kind = kind;
1097
- }
1098
- return result;
1099
- }
1100
- CodeAction2.create = create;
1101
- function is(value) {
1102
- var candidate = value;
1103
- return candidate && Is.string(candidate.title) && (candidate.diagnostics === void 0 || Is.typedArray(candidate.diagnostics, Diagnostic2.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));
1104
- }
1105
- CodeAction2.is = is;
1106
- })(CodeAction || (CodeAction = {}));
1107
- var CodeLens;
1108
- (function(CodeLens2) {
1109
- function create(range, data) {
1110
- var result = { range };
1111
- if (Is.defined(data)) {
1112
- result.data = data;
1113
- }
1114
- return result;
1115
- }
1116
- CodeLens2.create = create;
1117
- function is(value) {
1118
- var candidate = value;
1119
- return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
1120
- }
1121
- CodeLens2.is = is;
1122
- })(CodeLens || (CodeLens = {}));
1123
- var FormattingOptions;
1124
- (function(FormattingOptions5) {
1125
- function create(tabSize, insertSpaces) {
1126
- return { tabSize, insertSpaces };
1127
- }
1128
- FormattingOptions5.create = create;
1129
- function is(value) {
1130
- var candidate = value;
1131
- return Is.defined(candidate) && Is.uinteger(candidate.tabSize) && Is.boolean(candidate.insertSpaces);
1132
- }
1133
- FormattingOptions5.is = is;
1134
- })(FormattingOptions || (FormattingOptions = {}));
1135
- var DocumentLink;
1136
- (function(DocumentLink2) {
1137
- function create(range, target, data) {
1138
- return { range, target, data };
1139
- }
1140
- DocumentLink2.create = create;
1141
- function is(value) {
1142
- var candidate = value;
1143
- return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
1144
- }
1145
- DocumentLink2.is = is;
1146
- })(DocumentLink || (DocumentLink = {}));
1147
- var SelectionRange;
1148
- (function(SelectionRange2) {
1149
- function create(range, parent) {
1150
- return { range, parent };
1151
- }
1152
- SelectionRange2.create = create;
1153
- function is(value) {
1154
- var candidate = value;
1155
- return Is.objectLiteral(candidate) && Range.is(candidate.range) && (candidate.parent === void 0 || SelectionRange2.is(candidate.parent));
1156
- }
1157
- SelectionRange2.is = is;
1158
- })(SelectionRange || (SelectionRange = {}));
1159
- var SemanticTokenTypes;
1160
- (function(SemanticTokenTypes2) {
1161
- SemanticTokenTypes2["namespace"] = "namespace";
1162
- SemanticTokenTypes2["type"] = "type";
1163
- SemanticTokenTypes2["class"] = "class";
1164
- SemanticTokenTypes2["enum"] = "enum";
1165
- SemanticTokenTypes2["interface"] = "interface";
1166
- SemanticTokenTypes2["struct"] = "struct";
1167
- SemanticTokenTypes2["typeParameter"] = "typeParameter";
1168
- SemanticTokenTypes2["parameter"] = "parameter";
1169
- SemanticTokenTypes2["variable"] = "variable";
1170
- SemanticTokenTypes2["property"] = "property";
1171
- SemanticTokenTypes2["enumMember"] = "enumMember";
1172
- SemanticTokenTypes2["event"] = "event";
1173
- SemanticTokenTypes2["function"] = "function";
1174
- SemanticTokenTypes2["method"] = "method";
1175
- SemanticTokenTypes2["macro"] = "macro";
1176
- SemanticTokenTypes2["keyword"] = "keyword";
1177
- SemanticTokenTypes2["modifier"] = "modifier";
1178
- SemanticTokenTypes2["comment"] = "comment";
1179
- SemanticTokenTypes2["string"] = "string";
1180
- SemanticTokenTypes2["number"] = "number";
1181
- SemanticTokenTypes2["regexp"] = "regexp";
1182
- SemanticTokenTypes2["operator"] = "operator";
1183
- SemanticTokenTypes2["decorator"] = "decorator";
1184
- })(SemanticTokenTypes || (SemanticTokenTypes = {}));
1185
- var SemanticTokenModifiers;
1186
- (function(SemanticTokenModifiers2) {
1187
- SemanticTokenModifiers2["declaration"] = "declaration";
1188
- SemanticTokenModifiers2["definition"] = "definition";
1189
- SemanticTokenModifiers2["readonly"] = "readonly";
1190
- SemanticTokenModifiers2["static"] = "static";
1191
- SemanticTokenModifiers2["deprecated"] = "deprecated";
1192
- SemanticTokenModifiers2["abstract"] = "abstract";
1193
- SemanticTokenModifiers2["async"] = "async";
1194
- SemanticTokenModifiers2["modification"] = "modification";
1195
- SemanticTokenModifiers2["documentation"] = "documentation";
1196
- SemanticTokenModifiers2["defaultLibrary"] = "defaultLibrary";
1197
- })(SemanticTokenModifiers || (SemanticTokenModifiers = {}));
1198
- var SemanticTokens;
1199
- (function(SemanticTokens2) {
1200
- function is(value) {
1201
- var candidate = value;
1202
- return Is.objectLiteral(candidate) && (candidate.resultId === void 0 || typeof candidate.resultId === "string") && Array.isArray(candidate.data) && (candidate.data.length === 0 || typeof candidate.data[0] === "number");
1203
- }
1204
- SemanticTokens2.is = is;
1205
- })(SemanticTokens || (SemanticTokens = {}));
1206
- var InlineValueText;
1207
- (function(InlineValueText2) {
1208
- function create(range, text) {
1209
- return { range, text };
1210
- }
1211
- InlineValueText2.create = create;
1212
- function is(value) {
1213
- var candidate = value;
1214
- return candidate !== void 0 && candidate !== null && Range.is(candidate.range) && Is.string(candidate.text);
1215
- }
1216
- InlineValueText2.is = is;
1217
- })(InlineValueText || (InlineValueText = {}));
1218
- var InlineValueVariableLookup;
1219
- (function(InlineValueVariableLookup2) {
1220
- function create(range, variableName, caseSensitiveLookup) {
1221
- return { range, variableName, caseSensitiveLookup };
1222
- }
1223
- InlineValueVariableLookup2.create = create;
1224
- function is(value) {
1225
- var candidate = value;
1226
- return candidate !== void 0 && candidate !== null && Range.is(candidate.range) && Is.boolean(candidate.caseSensitiveLookup) && (Is.string(candidate.variableName) || candidate.variableName === void 0);
1227
- }
1228
- InlineValueVariableLookup2.is = is;
1229
- })(InlineValueVariableLookup || (InlineValueVariableLookup = {}));
1230
- var InlineValueEvaluatableExpression;
1231
- (function(InlineValueEvaluatableExpression2) {
1232
- function create(range, expression) {
1233
- return { range, expression };
1234
- }
1235
- InlineValueEvaluatableExpression2.create = create;
1236
- function is(value) {
1237
- var candidate = value;
1238
- return candidate !== void 0 && candidate !== null && Range.is(candidate.range) && (Is.string(candidate.expression) || candidate.expression === void 0);
1239
- }
1240
- InlineValueEvaluatableExpression2.is = is;
1241
- })(InlineValueEvaluatableExpression || (InlineValueEvaluatableExpression = {}));
1242
- var InlineValueContext;
1243
- (function(InlineValueContext2) {
1244
- function create(frameId, stoppedLocation) {
1245
- return { frameId, stoppedLocation };
1246
- }
1247
- InlineValueContext2.create = create;
1248
- function is(value) {
1249
- var candidate = value;
1250
- return Is.defined(candidate) && Range.is(value.stoppedLocation);
1251
- }
1252
- InlineValueContext2.is = is;
1253
- })(InlineValueContext || (InlineValueContext = {}));
1254
- var InlayHintKind;
1255
- (function(InlayHintKind2) {
1256
- InlayHintKind2.Type = 1;
1257
- InlayHintKind2.Parameter = 2;
1258
- function is(value) {
1259
- return value === 1 || value === 2;
1260
- }
1261
- InlayHintKind2.is = is;
1262
- })(InlayHintKind || (InlayHintKind = {}));
1263
- var InlayHintLabelPart;
1264
- (function(InlayHintLabelPart2) {
1265
- function create(value) {
1266
- return { value };
1267
- }
1268
- InlayHintLabelPart2.create = create;
1269
- function is(value) {
1270
- var candidate = value;
1271
- return Is.objectLiteral(candidate) && (candidate.tooltip === void 0 || Is.string(candidate.tooltip) || MarkupContent.is(candidate.tooltip)) && (candidate.location === void 0 || Location.is(candidate.location)) && (candidate.command === void 0 || Command.is(candidate.command));
1272
- }
1273
- InlayHintLabelPart2.is = is;
1274
- })(InlayHintLabelPart || (InlayHintLabelPart = {}));
1275
- var InlayHint;
1276
- (function(InlayHint2) {
1277
- function create(position, label, kind) {
1278
- var result = { position, label };
1279
- if (kind !== void 0) {
1280
- result.kind = kind;
1281
- }
1282
- return result;
1283
- }
1284
- InlayHint2.create = create;
1285
- function is(value) {
1286
- var candidate = value;
1287
- return Is.objectLiteral(candidate) && Position.is(candidate.position) && (Is.string(candidate.label) || Is.typedArray(candidate.label, InlayHintLabelPart.is)) && (candidate.kind === void 0 || InlayHintKind.is(candidate.kind)) && candidate.textEdits === void 0 || Is.typedArray(candidate.textEdits, TextEdit.is) && (candidate.tooltip === void 0 || Is.string(candidate.tooltip) || MarkupContent.is(candidate.tooltip)) && (candidate.paddingLeft === void 0 || Is.boolean(candidate.paddingLeft)) && (candidate.paddingRight === void 0 || Is.boolean(candidate.paddingRight));
1288
- }
1289
- InlayHint2.is = is;
1290
- })(InlayHint || (InlayHint = {}));
1291
- var WorkspaceFolder;
1292
- (function(WorkspaceFolder2) {
1293
- function is(value) {
1294
- var candidate = value;
1295
- return Is.objectLiteral(candidate) && URI.is(candidate.uri) && Is.string(candidate.name);
1296
- }
1297
- WorkspaceFolder2.is = is;
1298
- })(WorkspaceFolder || (WorkspaceFolder = {}));
1299
- var TextDocument;
1300
- (function(TextDocument2) {
1301
- function create(uri, languageId, version, content) {
1302
- return new FullTextDocument(uri, languageId, version, content);
1303
- }
1304
- TextDocument2.create = create;
1305
- function is(value) {
1306
- var candidate = value;
1307
- 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;
1308
- }
1309
- TextDocument2.is = is;
1310
- function applyEdits(document, edits) {
1311
- var text = document.getText();
1312
- var sortedEdits = mergeSort(edits, function(a, b) {
1313
- var diff = a.range.start.line - b.range.start.line;
1314
- if (diff === 0) {
1315
- return a.range.start.character - b.range.start.character;
1316
- }
1317
- return diff;
1318
- });
1319
- var lastModifiedOffset = text.length;
1320
- for (var i = sortedEdits.length - 1; i >= 0; i--) {
1321
- var e = sortedEdits[i];
1322
- var startOffset = document.offsetAt(e.range.start);
1323
- var endOffset = document.offsetAt(e.range.end);
1324
- if (endOffset <= lastModifiedOffset) {
1325
- text = text.substring(0, startOffset) + e.newText + text.substring(endOffset, text.length);
1326
- } else {
1327
- throw new Error("Overlapping edit");
1328
- }
1329
- lastModifiedOffset = startOffset;
1330
- }
1331
- return text;
1332
- }
1333
- TextDocument2.applyEdits = applyEdits;
1334
- function mergeSort(data, compare) {
1335
- if (data.length <= 1) {
1336
- return data;
1337
- }
1338
- var p = data.length / 2 | 0;
1339
- var left = data.slice(0, p);
1340
- var right = data.slice(p);
1341
- mergeSort(left, compare);
1342
- mergeSort(right, compare);
1343
- var leftIdx = 0;
1344
- var rightIdx = 0;
1345
- var i = 0;
1346
- while (leftIdx < left.length && rightIdx < right.length) {
1347
- var ret = compare(left[leftIdx], right[rightIdx]);
1348
- if (ret <= 0) {
1349
- data[i++] = left[leftIdx++];
1350
- } else {
1351
- data[i++] = right[rightIdx++];
1352
- }
1353
- }
1354
- while (leftIdx < left.length) {
1355
- data[i++] = left[leftIdx++];
1356
- }
1357
- while (rightIdx < right.length) {
1358
- data[i++] = right[rightIdx++];
1359
- }
1360
- return data;
1361
- }
1362
- })(TextDocument || (TextDocument = {}));
1363
- var FullTextDocument = (
1364
- /** @class */
1365
- function() {
1366
- function FullTextDocument2(uri, languageId, version, content) {
1367
- this._uri = uri;
1368
- this._languageId = languageId;
1369
- this._version = version;
1370
- this._content = content;
1371
- this._lineOffsets = void 0;
1372
- }
1373
- Object.defineProperty(FullTextDocument2.prototype, "uri", {
1374
- get: function() {
1375
- return this._uri;
1376
- },
1377
- enumerable: false,
1378
- configurable: true
1379
- });
1380
- Object.defineProperty(FullTextDocument2.prototype, "languageId", {
1381
- get: function() {
1382
- return this._languageId;
1383
- },
1384
- enumerable: false,
1385
- configurable: true
1386
- });
1387
- Object.defineProperty(FullTextDocument2.prototype, "version", {
1388
- get: function() {
1389
- return this._version;
1390
- },
1391
- enumerable: false,
1392
- configurable: true
1393
- });
1394
- FullTextDocument2.prototype.getText = function(range) {
1395
- if (range) {
1396
- var start = this.offsetAt(range.start);
1397
- var end = this.offsetAt(range.end);
1398
- return this._content.substring(start, end);
1399
- }
1400
- return this._content;
1401
- };
1402
- FullTextDocument2.prototype.update = function(event, version) {
1403
- this._content = event.text;
1404
- this._version = version;
1405
- this._lineOffsets = void 0;
1406
- };
1407
- FullTextDocument2.prototype.getLineOffsets = function() {
1408
- if (this._lineOffsets === void 0) {
1409
- var lineOffsets = [];
1410
- var text = this._content;
1411
- var isLineStart = true;
1412
- for (var i = 0; i < text.length; i++) {
1413
- if (isLineStart) {
1414
- lineOffsets.push(i);
1415
- isLineStart = false;
1416
- }
1417
- var ch = text.charAt(i);
1418
- isLineStart = ch === "\r" || ch === "\n";
1419
- if (ch === "\r" && i + 1 < text.length && text.charAt(i + 1) === "\n") {
1420
- i++;
1421
- }
1422
- }
1423
- if (isLineStart && text.length > 0) {
1424
- lineOffsets.push(text.length);
1425
- }
1426
- this._lineOffsets = lineOffsets;
1427
- }
1428
- return this._lineOffsets;
1429
- };
1430
- FullTextDocument2.prototype.positionAt = function(offset) {
1431
- offset = Math.max(Math.min(offset, this._content.length), 0);
1432
- var lineOffsets = this.getLineOffsets();
1433
- var low = 0, high = lineOffsets.length;
1434
- if (high === 0) {
1435
- return Position.create(0, offset);
1436
- }
1437
- while (low < high) {
1438
- var mid = Math.floor((low + high) / 2);
1439
- if (lineOffsets[mid] > offset) {
1440
- high = mid;
1441
- } else {
1442
- low = mid + 1;
1443
- }
1444
- }
1445
- var line = low - 1;
1446
- return Position.create(line, offset - lineOffsets[line]);
1447
- };
1448
- FullTextDocument2.prototype.offsetAt = function(position) {
1449
- var lineOffsets = this.getLineOffsets();
1450
- if (position.line >= lineOffsets.length) {
1451
- return this._content.length;
1452
- } else if (position.line < 0) {
1453
- return 0;
1454
- }
1455
- var lineOffset = lineOffsets[position.line];
1456
- var nextLineOffset = position.line + 1 < lineOffsets.length ? lineOffsets[position.line + 1] : this._content.length;
1457
- return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);
1458
- };
1459
- Object.defineProperty(FullTextDocument2.prototype, "lineCount", {
1460
- get: function() {
1461
- return this.getLineOffsets().length;
1462
- },
1463
- enumerable: false,
1464
- configurable: true
1465
- });
1466
- return FullTextDocument2;
1467
- }()
1468
- );
1469
- var Is;
1470
- (function(Is2) {
1471
- var toString = Object.prototype.toString;
1472
- function defined(value) {
1473
- return typeof value !== "undefined";
1474
- }
1475
- Is2.defined = defined;
1476
- function undefined2(value) {
1477
- return typeof value === "undefined";
1478
- }
1479
- Is2.undefined = undefined2;
1480
- function boolean(value) {
1481
- return value === true || value === false;
1482
- }
1483
- Is2.boolean = boolean;
1484
- function string(value) {
1485
- return toString.call(value) === "[object String]";
1486
- }
1487
- Is2.string = string;
1488
- function number(value) {
1489
- return toString.call(value) === "[object Number]";
1490
- }
1491
- Is2.number = number;
1492
- function numberRange(value, min, max) {
1493
- return toString.call(value) === "[object Number]" && min <= value && value <= max;
1494
- }
1495
- Is2.numberRange = numberRange;
1496
- function integer2(value) {
1497
- return toString.call(value) === "[object Number]" && -2147483648 <= value && value <= 2147483647;
1498
- }
1499
- Is2.integer = integer2;
1500
- function uinteger2(value) {
1501
- return toString.call(value) === "[object Number]" && 0 <= value && value <= 2147483647;
1502
- }
1503
- Is2.uinteger = uinteger2;
1504
- function func(value) {
1505
- return toString.call(value) === "[object Function]";
1506
- }
1507
- Is2.func = func;
1508
- function objectLiteral(value) {
1509
- return value !== null && typeof value === "object";
1510
- }
1511
- Is2.objectLiteral = objectLiteral;
1512
- function typedArray(value, check) {
1513
- return Array.isArray(value) && value.every(check);
1514
- }
1515
- Is2.typedArray = typedArray;
1516
- })(Is || (Is = {}));
1517
-
1518
- // src/services/languageKeywords.ts
1519
- var ArcadeKeywords = Object.values(Keywords);
1520
- var ArcadeLiterals = Object.values(Literals);
1521
-
1522
- // src/services/arcade-completetion/snippets.ts
1523
- ArcadeLiterals.map((label) => ({ label, kind: CompletionItemKind.Constant }));
1524
- ArcadeKeywords.map((label) => ({ label, kind: CompletionItemKind.Keyword }));
1525
-
1526
- const operators = [
1527
- "<=",
1528
- ">=",
1529
- "==",
1530
- "!=",
1531
- "+",
1532
- "-",
1533
- "*",
1534
- "/",
1535
- "%",
1536
- "++",
1537
- "--",
1538
- "<<",
1539
- ">>",
1540
- ">>>",
1541
- "&",
1542
- "|",
1543
- "^",
1544
- "!",
1545
- "~",
1546
- "&&",
1547
- "||",
1548
- "=",
1549
- "+=",
1550
- "-=",
1551
- "*=",
1552
- "**=",
1553
- "/=",
1554
- "%="
1555
- ];
1556
- const arcadeLanguageConfiguration = {
1557
- // the default separators except `@$`
1558
- wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
1559
- comments: {
1560
- lineComment: "//",
1561
- blockComment: ["/*", "*/"]
1562
- },
1563
- brackets: [
1564
- ["{", "}"],
1565
- ["[", "]"],
1566
- ["(", ")"]
1567
- ],
1568
- autoClosingPairs: [
1569
- { open: "{", close: "}" },
1570
- { open: "[", close: "]" },
1571
- { open: "(", close: ")" },
1572
- { open: '"', close: '"', notIn: ["string"] },
1573
- { open: "'", close: "'", notIn: ["string", "comment"] },
1574
- { open: "`", close: "`", notIn: ["string", "comment"] }
1575
- ],
1576
- autoCloseBefore: ";:.,=}])` \n\t",
1577
- folding: {
1578
- markers: {
1579
- start: new RegExp("^\\s*//\\s*#?region\\b"),
1580
- end: new RegExp("^\\s*//\\s*#?endregion\\b")
1581
- }
1582
- },
1583
- indentationRules: {
1584
- // ^(.*\*/)?\s*\}.*$
1585
- decreaseIndentPattern: /^((?!.*?\/\*).*\*\/)?\s*[\}\]\)].*$/,
1586
- // ^.*\{[^}"']*$
1587
- increaseIndentPattern: /^((?!\/\/).)*(\{[^}"'`]*|\([^)"'`]*|\[[^\]"'`]*)$/
1588
- }
1589
- };
1590
- const arcadeMonarchLanguage = {
1591
- // Set defaultToken to invalid to see what you do not tokenize yet
1592
- defaultToken: "invalid",
1593
- tokenPostfix: ".arc",
1594
- // Arcade is case insensitive
1595
- ignoreCase: true,
1596
- // builtinFunctions: Array.from(arcadeService.FunctionNames),
1597
- // Arcade keywords. 'from' is a special case as we want to treat it as a keyword in
1598
- // import statement but as an identifer in var statement.
1599
- keywords: ArcadeKeywords.filter((k) => k !== "from"),
1600
- operators,
1601
- constants: ["true", "false", "null"],
1602
- // we include these common regular expressions
1603
- symbols: /[=><!~?:&|+\-*\/\^%]+/,
1604
- escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
1605
- digits: /\d+(_+\d+)*/,
1606
- octaldigits: /[0-7]+(_+[0-7]+)*/,
1607
- binarydigits: /[0-1]+(_+[0-1]+)*/,
1608
- hexdigits: /[[0-9a-fA-F]+(_+[0-9a-fA-F]+)*/,
1609
- regexpctl: /[(){}\[\]\$\^|\-*+?\.]/,
1610
- regexpesc: /\\(?:[bBdDfnrstvwWn0\\\/]|@regexpctl|c[A-Z]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4})/,
1611
- // The main tokenizer for our languages
1612
- tokenizer: {
1613
- root: [[/[{}]/, "delimiter.bracket"], { include: "common" }],
1614
- common: [
1615
- // import statement. import followed by a white space
1616
- [/import(?=\s)/, { token: "keyword", next: "@import" }],
1617
- // identifiers and keywords
1618
- [
1619
- /[a-z_$][\w$]*/,
1620
- {
1621
- cases: {
1622
- "@constants": "constant",
1623
- "@keywords": "keyword",
1624
- "@default": "identifier"
1625
- }
1626
- }
1627
- ],
1628
- // whitespace
1629
- { include: "@whitespace" },
1630
- // regular expression: ensure it is terminated before beginning (otherwise it is an opeator)
1631
- [
1632
- /\/(?=([^\\\/]|\\.)+\/([gimsuy]*)(\s*)(\.|;|\/|,|\)|\]|\}|$))/,
1633
- { token: "regexp", bracket: "@open", next: "@regexp" }
1634
- ],
1635
- // delimiters and operators
1636
- [/[()\[\]]/, "@brackets"],
1637
- [/[<>](?!@symbols)/, "@brackets"],
1638
- [
1639
- /@symbols/,
1640
- {
1641
- cases: {
1642
- "@operators": "delimiter",
1643
- "@default": ""
1644
- }
1645
- }
1646
- ],
1647
- // numbers
1648
- [/(@digits)[eE]([\-+]?(@digits))?/, "number"],
1649
- [/(@digits)\.(@digits)([eE][\-+]?(@digits))?/, "number"],
1650
- [/0[xX](@hexdigits)/, "number"],
1651
- [/0[oO]?(@octaldigits)/, "number"],
1652
- [/0[bB](@binarydigits)/, "number"],
1653
- [/(@digits)/, "number"],
1654
- // delimiter: after number because of .\d floats
1655
- [/[;,.]/, "delimiter"],
1656
- // strings
1657
- [/"([^"\\]|\\.)*$/, "string.invalid"],
1658
- [/'([^'\\]|\\.)*$/, "string.invalid"],
1659
- [/"/, "string", "@string_double"],
1660
- [/'/, "string", "@string_single"],
1661
- [/`/, "string", "@string_backtick"]
1662
- ],
1663
- import: [
1664
- // import keyword
1665
- [/import(?=\s)/, { token: "keyword" }],
1666
- // whitespace
1667
- { include: "@whitespace" },
1668
- // identifier
1669
- [/[a-z_$][\w$]*/, "identifier"],
1670
- // whitespace
1671
- { include: "@whitespace" },
1672
- // from keyword
1673
- [/from/, { token: "keyword", next: "@popall" }]
1674
- ],
1675
- whitespace: [
1676
- [/[ \t\r\n]+/, ""],
1677
- [/\/\*/, "comment", "@comment"],
1678
- [/\/\/.*$/, "comment"]
1679
- ],
1680
- comment: [
1681
- [/[^\/*]+/, "comment"],
1682
- [/\*\//, "comment", "@pop"],
1683
- [/[\/*]/, "comment"]
1684
- ],
1685
- // We match regular expression quite precisely
1686
- regexp: [
1687
- [/(\{)(\d+(?:,\d*)?)(\})/, ["regexp.escape.control", "regexp.escape.control", "regexp.escape.control"]],
1688
- [
1689
- /(\[)(\^?)(?=(?:[^\]\\\/]|\\.)+)/,
1690
- ["regexp.escape.control", { token: "regexp.escape.control", next: "@regexrange" }]
1691
- ],
1692
- [/(\()(\?:|\?=|\?!)/, ["regexp.escape.control", "regexp.escape.control"]],
1693
- [/[()]/, "regexp.escape.control"],
1694
- [/@regexpctl/, "regexp.escape.control"],
1695
- [/[^\\\/]/, "regexp"],
1696
- [/@regexpesc/, "regexp.escape"],
1697
- [/\\\./, "regexp.invalid"],
1698
- [/(\/)([gimsuy]*)/, [{ token: "regexp", bracket: "@close", next: "@pop" }, "keyword.other"]]
1699
- ],
1700
- regexrange: [
1701
- [/-/, "regexp.escape.control"],
1702
- [/\^/, "regexp.invalid"],
1703
- [/@regexpesc/, "regexp.escape"],
1704
- [/[^\]]/, "regexp"],
1705
- [/\]/, { token: "regexp.escape.control", next: "@pop", bracket: "@close" }]
1706
- ],
1707
- string_double: [
1708
- [/[^\\"]+/, "string"],
1709
- [/@escapes/, "string.escape"],
1710
- [/\\./, "string.escape.invalid"],
1711
- [/"/, "string", "@pop"]
1712
- ],
1713
- string_single: [
1714
- [/[^\\']+/, "string"],
1715
- [/@escapes/, "string.escape"],
1716
- [/\\./, "string.escape.invalid"],
1717
- [/'/, "string", "@pop"]
1718
- ],
1719
- string_backtick: [
1720
- [/\$\{/, { token: "delimiter.bracket", next: "@bracketCounting" }],
1721
- [/[^\\`$]+/, "string"],
1722
- [/@escapes/, "string.escape"],
1723
- [/\\./, "string.escape.invalid"],
1724
- [/`/, "string", "@pop"]
1725
- ],
1726
- bracketCounting: [
1727
- [/\{/, "delimiter.bracket", "@bracketCounting"],
1728
- [/\}/, "delimiter.bracket", "@pop"],
1729
- { include: "common" }
1730
- ]
1731
- }
1732
- };
1733
-
1734
- //#region Diagnostic
1735
- class DiagnosticsAdapter {
1736
- constructor(_languageId, _worker, { defaults, diagnosticsService }) {
1737
- this._languageId = _languageId;
1738
- this._worker = _worker;
1739
- this._disposables = [];
1740
- this._listener = Object.create(null);
1741
- this._diagnosticsService = diagnosticsService;
1742
- this._defaults = defaults;
1743
- const onModelAdd = (model) => {
1744
- const languageId = model.getLanguageId();
1745
- if (languageId !== this._languageId) {
1746
- return;
1747
- }
1748
- let handle;
1749
- this._listener[model.uri.toString()] = model.onDidChangeContent(() => {
1750
- window.clearTimeout(handle);
1751
- handle = window.setTimeout(() => this._doValidate(model, languageId), 500);
1752
- });
1753
- this._doValidate(model, languageId);
1754
- };
1755
- const onModelRemoved = (model) => {
1756
- const uriStr = model.uri.toString();
1757
- editor.setModelMarkers(model, this._languageId, []);
1758
- const listener = this._listener[uriStr];
1759
- if (listener) {
1760
- listener.dispose();
1761
- delete this._listener[uriStr];
1762
- }
1763
- };
1764
- this._disposables.push(editor.onDidCreateModel(onModelAdd));
1765
- this._disposables.push(editor.onWillDisposeModel((model) => {
1766
- onModelRemoved(model);
1767
- }));
1768
- this._disposables.push(editor.onDidChangeModelLanguage((event) => {
1769
- onModelRemoved(event.model);
1770
- onModelAdd(event.model);
1771
- }));
1772
- this._disposables.push(defaults.onDidChange(() => {
1773
- editor.getModels().forEach((model) => {
1774
- if (model.getLanguageId() === this._languageId) {
1775
- onModelRemoved(model);
1776
- onModelAdd(model);
1777
- }
1778
- });
1779
- }));
1780
- this._disposables.push(defaults.onModelContextDidChange((key) => {
1781
- editor.getModels().forEach((model) => {
1782
- if (model.getLanguageId() === this._languageId && model.uri.toString() === key) {
1783
- this._doValidate(model, this._languageId);
1784
- }
1785
- });
1786
- }));
1787
- this._disposables.push({
1788
- dispose: () => {
1789
- for (const key in this._listener) {
1790
- this._listener[key].dispose();
1791
- }
1792
- }
1793
- });
1794
- editor.getModels().forEach(onModelAdd);
1795
- }
1796
- dispose() {
1797
- this._disposables.forEach((d) => d && d.dispose());
1798
- this._disposables = [];
1799
- }
1800
- async _doValidate(model, languageId) {
1801
- if (!model.isAttachedToEditor()) {
1802
- return;
1803
- }
1804
- try {
1805
- const workerProxy = await this._worker(model.uri);
1806
- const context = this._defaults.getApiContextForModel(model.uri);
1807
- const diagnostics = await workerProxy.doValidation(model.uri.toString(), context);
1808
- const markers = diagnostics.map((d) => toMarker(model.uri, d));
1809
- this._diagnosticsService.fireDiagnosticsChange(model.uri, diagnostics);
1810
- editor.setModelMarkers(model, languageId, markers);
1811
- }
1812
- catch (err) {
1813
- console.error(err);
1814
- }
1815
- }
1816
- }
1817
- function toSeverity(languageServiceSeverity) {
1818
- switch (languageServiceSeverity) {
1819
- case DiagnosticSeverity$1.Error:
1820
- return MarkerSeverity.Error;
1821
- case DiagnosticSeverity$1.Warning:
1822
- return MarkerSeverity.Warning;
1823
- case DiagnosticSeverity$1.Information:
1824
- return MarkerSeverity.Info;
1825
- case DiagnosticSeverity$1.Hint:
1826
- return MarkerSeverity.Hint;
1827
- default:
1828
- return MarkerSeverity.Info;
1829
- }
1830
- }
1831
- function toMarker(_resource, diag) {
1832
- // Diagnostics positions are zero-based, MarkerData are 1-based
1833
- return {
1834
- severity: toSeverity(diag.severity),
1835
- startLineNumber: diag.range.start.line + 1,
1836
- startColumn: diag.range.start.character + 1,
1837
- endLineNumber: diag.range.end.line + 1,
1838
- endColumn: diag.range.end.character + 1,
1839
- message: diag.message
1840
- };
1841
- }
1842
- //#endregion
1843
- //#region Completion
1844
- function fromPosition(position) {
1845
- // Language service is zero based
1846
- return { character: position.column - 1, line: position.lineNumber - 1 };
1847
- }
1848
- function toRange(range) {
1849
- return new Range$1(range.start.line + 1, range.start.character + 1, range.end.line + 1, range.end.character + 1);
1850
- }
1851
- function toTextEdit(textEdit) {
1852
- return {
1853
- range: toRange(textEdit.range),
1854
- text: textEdit.newText
1855
- };
1856
- }
1857
- function isInsertReplaceEdit(edit) {
1858
- return (typeof edit.insert !== "undefined" && typeof edit.replace !== "undefined");
1859
- }
1860
- function toCompletionItemKind(kind) {
1861
- const mItemKind = languages.CompletionItemKind;
1862
- switch (kind) {
1863
- case CompletionItemKind$1.Text:
1864
- return mItemKind.Text;
1865
- case CompletionItemKind$1.Method:
1866
- return mItemKind.Method;
1867
- case CompletionItemKind$1.Function:
1868
- return mItemKind.Function;
1869
- case CompletionItemKind$1.Constructor:
1870
- return mItemKind.Constructor;
1871
- case CompletionItemKind$1.Field:
1872
- return mItemKind.Field;
1873
- case CompletionItemKind$1.Variable:
1874
- return mItemKind.Variable;
1875
- case CompletionItemKind$1.Class:
1876
- return mItemKind.Class;
1877
- case CompletionItemKind$1.Interface:
1878
- return mItemKind.Interface;
1879
- case CompletionItemKind$1.Module:
1880
- return mItemKind.Module;
1881
- case CompletionItemKind$1.Property:
1882
- return mItemKind.Property;
1883
- case CompletionItemKind$1.Unit:
1884
- return mItemKind.Unit;
1885
- case CompletionItemKind$1.Value:
1886
- return mItemKind.Value;
1887
- case CompletionItemKind$1.Enum:
1888
- return mItemKind.Enum;
1889
- case CompletionItemKind$1.Keyword:
1890
- return mItemKind.Keyword;
1891
- case CompletionItemKind$1.Snippet:
1892
- return mItemKind.Snippet;
1893
- case CompletionItemKind$1.Color:
1894
- return mItemKind.Color;
1895
- case CompletionItemKind$1.File:
1896
- return mItemKind.File;
1897
- case CompletionItemKind$1.Reference:
1898
- return mItemKind.Reference;
1899
- case CompletionItemKind$1.Folder:
1900
- return mItemKind.Folder;
1901
- case CompletionItemKind$1.EnumMember:
1902
- return mItemKind.EnumMember;
1903
- case CompletionItemKind$1.Constant:
1904
- return mItemKind.Constant;
1905
- case CompletionItemKind$1.Struct:
1906
- return mItemKind.Struct;
1907
- case CompletionItemKind$1.Event:
1908
- return mItemKind.Event;
1909
- case CompletionItemKind$1.Operator:
1910
- return mItemKind.Operator;
1911
- case CompletionItemKind$1.TypeParameter:
1912
- return mItemKind.TypeParameter;
1913
- }
1914
- return mItemKind.Property;
1915
- }
1916
- class CompletionProvider {
1917
- constructor(_worker, _defaults) {
1918
- this._worker = _worker;
1919
- this._defaults = _defaults;
1920
- this.triggerCharacters = [".", "("];
1921
- }
1922
- async provideCompletionItems(model, position
1923
- // _context: languages.CompletionContext,
1924
- // _token: CancellationToken,
1925
- ) {
1926
- const worker = await this._worker(model.uri);
1927
- const context = this._defaults.getApiContextForModel(model.uri);
1928
- const completionList = await worker.doComplete(model.uri.toString(), fromPosition(position), context);
1929
- if (!completionList) {
1930
- return;
1931
- }
1932
- const wordInfo = model.getWordUntilPosition(position);
1933
- const wordRange = new Range$1(position.lineNumber, wordInfo.startColumn, position.lineNumber, wordInfo.endColumn);
1934
- const items = completionList.items.map((entry) => {
1935
- const item = {
1936
- label: entry.label,
1937
- insertText: entry.insertText || entry.label,
1938
- sortText: entry.sortText,
1939
- filterText: entry.filterText,
1940
- detail: entry.detail,
1941
- range: wordRange,
1942
- kind: toCompletionItemKind(entry.kind)
1943
- };
1944
- if (entry.textEdit) {
1945
- if (isInsertReplaceEdit(entry.textEdit)) {
1946
- item.range = {
1947
- insert: toRange(entry.textEdit.insert),
1948
- replace: toRange(entry.textEdit.replace)
1949
- };
1950
- }
1951
- else {
1952
- item.range = toRange(entry.textEdit.range);
1953
- }
1954
- item.insertText = entry.textEdit.newText;
1955
- }
1956
- if (entry.additionalTextEdits) {
1957
- item.additionalTextEdits = entry.additionalTextEdits.map(toTextEdit);
1958
- }
1959
- if (entry.insertTextFormat === InsertTextFormat$1.Snippet) {
1960
- item.insertTextRules = languages.CompletionItemInsertTextRule.InsertAsSnippet;
1961
- }
1962
- if (entry.documentation) {
1963
- if (typeof entry.documentation === "string") {
1964
- item.documentation = entry.documentation;
1965
- }
1966
- else {
1967
- item.documentation = {
1968
- supportThemeIcons: false,
1969
- value: entry.documentation.value,
1970
- supportHtml: true
1971
- };
1972
- }
1973
- }
1974
- return item;
1975
- });
1976
- return {
1977
- incomplete: completionList.isIncomplete,
1978
- suggestions: items
1979
- };
1980
- }
1981
- }
1982
- //#endregion
1983
- //#region Formatter
1984
- class FormattingProvider {
1985
- constructor(_worker, _defaults) {
1986
- this._worker = _worker;
1987
- this._defaults = _defaults;
1988
- }
1989
- async provideDocumentFormattingEdits(model
1990
- // _options: languages.FormattingOptions,
1991
- // _token: CancellationToken,
1992
- ) {
1993
- const worker = await this._worker(model.uri);
1994
- const context = this._defaults.getApiContextForModel(model.uri.toString());
1995
- const edits = await worker.doFormat(model.uri.toString(), context);
1996
- if (!edits) {
1997
- return [];
1998
- }
1999
- return edits.map((e) => ({ range: toRange(e.range), text: e.newText }));
2000
- }
2001
- }
2002
- //#endregion
2003
-
2004
- /**
2005
- * Manager to create our arcade worker and client proxy
2006
- */
2007
- class WorkerManager {
2008
- constructor(_defaults) {
2009
- this._defaults = _defaults;
2010
- this._worker = null;
2011
- this._client = null;
2012
- // Observes the arcade defaults. If modified then stop the worker.
2013
- this._configChangeListener = this._defaults.onDidChange(() => this.stopWorker());
2014
- }
2015
- dispose() {
2016
- this._configChangeListener.dispose();
2017
- this.stopWorker();
2018
- }
2019
- stopWorker() {
2020
- if (this._worker) {
2021
- this._worker.dispose();
2022
- this._worker = null;
2023
- }
2024
- this._client = null;
2025
- }
2026
- _getClientProxy() {
2027
- // We used createWebWorker to create or run the web worker if it isn’t already created.
2028
- // Otherwise, we get and return the proxy client.
2029
- if (!this._client) {
2030
- const { languageId, languageOptions } = this._defaults;
2031
- this._worker = editor.createWebWorker({
2032
- moduleId: "ArcadeWorker",
2033
- label: languageId,
2034
- createData: {
2035
- languageId,
2036
- languageOptions
2037
- }
2038
- });
2039
- this._client = this._worker.getProxy();
2040
- }
2041
- return this._client;
2042
- }
2043
- async getLanguageServiceWorker(...resources) {
2044
- const _client = await this._getClientProxy();
2045
- await this._worker?.withSyncedResources(resources);
2046
- return _client;
2047
- }
2048
- }
2049
-
2050
- let arcadeWorker;
2051
- /**
2052
- * Returns the arcade worker for the model uris.
2053
- * @param uris The model uris for which to get the worker.
2054
- * @returns The arcade worker.
2055
- */
2056
- async function getArcadeWorker(...uris) {
2057
- return new Promise((resolve, reject) => {
2058
- if (!arcadeWorker) {
2059
- return reject("TypeScript not registered!");
2060
- }
2061
- resolve(arcadeWorker(...uris));
2062
- });
2063
- }
2064
- /**
2065
- * The Arcade Language Diagnostic Service.
2066
- * Consumers can listen to the diagnostics change event to get notified when the diagnostics change.
2067
- */
2068
- class ArcadeDiagnosticService {
2069
- constructor() {
2070
- this._onDiagnosticsChange = new Emitter();
2071
- }
2072
- /**
2073
- * An event to signal changes to the diagnostics.
2074
- * The event value is the uri string and the diagnostics.
2075
- */
2076
- get onDiagnosticsChange() {
2077
- return this._onDiagnosticsChange.event;
2078
- }
2079
- /**
2080
- * Fires the diagnostics change event.
2081
- * @param uri The uri of the model for which the diagnostics changed.
2082
- * @param diagnostics The diagnostics for the model.
2083
- */
2084
- fireDiagnosticsChange(uri, diagnostics) {
2085
- this._onDiagnosticsChange.fire({ uri, diagnostics });
2086
- }
2087
- }
2088
- const arcadeDiagnosticService = new ArcadeDiagnosticService();
2089
- /**
2090
- * Get the Arcade Diagnostic Service.
2091
- * @returns The Arcade Language Diagnostic Service.
2092
- */
2093
- function getArcadeDiagnosticService() {
2094
- return arcadeDiagnosticService;
2095
- }
2096
- function setupMode(arcadeDefaults) {
2097
- const client = new WorkerManager(arcadeDefaults);
2098
- const workerAccessor = (...uris) => client.getLanguageServiceWorker(...uris);
2099
- arcadeWorker = workerAccessor;
2100
- // Use the arcade Monarch Json to define the highlighting
2101
- languages.setMonarchTokensProvider(arcadeDefaults.languageId, arcadeMonarchLanguage);
2102
- languages.setLanguageConfiguration(arcadeDefaults.languageId, arcadeLanguageConfiguration);
2103
- // Creates and registers a Completion Adapter
2104
- languages.registerCompletionItemProvider(arcadeDefaults.languageId, new CompletionProvider(workerAccessor, arcadeDefaults));
2105
- // Creates and registers a Formatter
2106
- languages.registerDocumentFormattingEditProvider(arcadeDefaults.languageId, new FormattingProvider(workerAccessor, arcadeDefaults));
2107
- // Creates a Diagnostic Adapter
2108
- new DiagnosticsAdapter(arcadeDefaults.languageId, workerAccessor, {
2109
- defaults: arcadeDefaults,
2110
- diagnosticsService: arcadeDiagnosticService
2111
- });
2112
- }
2113
-
2114
- export { getArcadeDiagnosticService, getArcadeWorker, setupMode };