@depup/vscode-languageserver-types 3.18.3-depup.0

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.
@@ -0,0 +1,2465 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ /* --------------------------------------------------------------------------------------------
11
+ * Copyright (c) Microsoft Corporation. All rights reserved.
12
+ * Licensed under the MIT License. See License.txt in the project root for license information.
13
+ * ------------------------------------------------------------------------------------------ */
14
+ 'use strict';
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.TextDocument = exports.EOL = exports.WorkspaceFolder = exports.InlineCompletionContext = exports.SelectedCompletionInfo = exports.InlineCompletionTriggerKind = exports.InlineCompletionList = exports.InlineCompletionItem = exports.StringValue = exports.InlayHint = exports.InlayHintLabelPart = exports.InlayHintKind = exports.InlineValueContext = exports.InlineValueEvaluatableExpression = exports.InlineValueVariableLookup = exports.InlineValueText = exports.SemanticTokens = exports.SemanticTokenModifiers = exports.SemanticTokenTypes = exports.SelectionRange = exports.DocumentLink = exports.FormattingOptions = exports.CodeLens = exports.CodeAction = exports.CodeActionTag = exports.CodeActionContext = exports.CodeActionTriggerKind = exports.CodeActionKind = exports.DocumentSymbol = exports.WorkspaceSymbol = exports.SymbolInformation = exports.SymbolTag = exports.SymbolKind = exports.DocumentHighlight = exports.DocumentHighlightKind = exports.SignatureInformation = exports.ParameterInformation = exports.Hover = exports.MarkedString = exports.CompletionList = exports.CompletionItem = exports.CompletionItemLabelDetails = exports.ApplyKind = exports.InsertTextMode = exports.InsertReplaceEdit = exports.CompletionItemTag = exports.InsertTextFormat = exports.CompletionItemKind = exports.MarkupContent = exports.MarkupKind = exports.TextDocumentItem = exports.LanguageKind = exports.OptionalVersionedTextDocumentIdentifier = exports.VersionedTextDocumentIdentifier = exports.TextDocumentIdentifier = exports.WorkspaceChange = exports.SnippetTextEdit = exports.WorkspaceEdit = exports.DeleteFile = exports.RenameFile = exports.CreateFile = exports.TextDocumentEdit = exports.AnnotatedTextEdit = exports.ChangeAnnotationIdentifier = exports.ChangeAnnotation = exports.TextEdit = exports.Command = exports.Diagnostic = exports.CodeDescription = exports.DiagnosticTag = exports.DiagnosticSeverity = exports.DiagnosticRelatedInformation = exports.FoldingRange = exports.FoldingRangeKind = exports.ColorPresentation = exports.ColorInformation = exports.Color = exports.LocationLink = exports.Location = exports.Range = exports.Position = exports.uinteger = exports.integer = exports.URI = exports.DocumentUri = void 0;
17
+ var DocumentUri;
18
+ (function (DocumentUri) {
19
+ function is(value) {
20
+ return typeof value === 'string';
21
+ }
22
+ DocumentUri.is = is;
23
+ })(DocumentUri || (exports.DocumentUri = DocumentUri = {}));
24
+ var URI;
25
+ (function (URI) {
26
+ function is(value) {
27
+ return typeof value === 'string';
28
+ }
29
+ URI.is = is;
30
+ })(URI || (exports.URI = URI = {}));
31
+ var integer;
32
+ (function (integer) {
33
+ integer.MIN_VALUE = -2147483648;
34
+ integer.MAX_VALUE = 2147483647;
35
+ function is(value) {
36
+ return typeof value === 'number' && integer.MIN_VALUE <= value && value <= integer.MAX_VALUE;
37
+ }
38
+ integer.is = is;
39
+ })(integer || (exports.integer = integer = {}));
40
+ var uinteger;
41
+ (function (uinteger) {
42
+ uinteger.MIN_VALUE = 0;
43
+ uinteger.MAX_VALUE = 2147483647;
44
+ function is(value) {
45
+ return typeof value === 'number' && uinteger.MIN_VALUE <= value && value <= uinteger.MAX_VALUE;
46
+ }
47
+ uinteger.is = is;
48
+ })(uinteger || (exports.uinteger = uinteger = {}));
49
+ /**
50
+ * The Position namespace provides helper functions to work with
51
+ * {@link Position} literals.
52
+ */
53
+ var Position;
54
+ (function (Position) {
55
+ /**
56
+ * Creates a new Position literal from the given line and character.
57
+ * @param line The position's line.
58
+ * @param character The position's character.
59
+ */
60
+ function create(line, character) {
61
+ if (line === Number.MAX_VALUE) {
62
+ line = uinteger.MAX_VALUE;
63
+ }
64
+ if (character === Number.MAX_VALUE) {
65
+ character = uinteger.MAX_VALUE;
66
+ }
67
+ return { line: line, character: character };
68
+ }
69
+ Position.create = create;
70
+ /**
71
+ * Checks whether the given literal conforms to the {@link Position} interface.
72
+ */
73
+ function is(value) {
74
+ var candidate = value;
75
+ return Is.objectLiteral(candidate) && Is.uinteger(candidate.line) && Is.uinteger(candidate.character);
76
+ }
77
+ Position.is = is;
78
+ })(Position || (exports.Position = Position = {}));
79
+ /**
80
+ * The Range namespace provides helper functions to work with
81
+ * {@link Range} literals.
82
+ */
83
+ var Range;
84
+ (function (Range) {
85
+ function create(one, two, three, four) {
86
+ if (Is.uinteger(one) && Is.uinteger(two) && Is.uinteger(three) && Is.uinteger(four)) {
87
+ return { start: Position.create(one, two), end: Position.create(three, four) };
88
+ }
89
+ else if (Position.is(one) && Position.is(two)) {
90
+ return { start: one, end: two };
91
+ }
92
+ else {
93
+ throw new Error("Range#create called with invalid arguments[".concat(one, ", ").concat(two, ", ").concat(three, ", ").concat(four, "]"));
94
+ }
95
+ }
96
+ Range.create = create;
97
+ /**
98
+ * Checks whether the given literal conforms to the {@link Range} interface.
99
+ */
100
+ function is(value) {
101
+ var candidate = value;
102
+ return Is.objectLiteral(candidate) && Position.is(candidate.start) && Position.is(candidate.end);
103
+ }
104
+ Range.is = is;
105
+ })(Range || (exports.Range = Range = {}));
106
+ /**
107
+ * The Location namespace provides helper functions to work with
108
+ * {@link Location} literals.
109
+ */
110
+ var Location;
111
+ (function (Location) {
112
+ /**
113
+ * Creates a Location literal.
114
+ * @param uri The location's uri.
115
+ * @param range The location's range.
116
+ */
117
+ function create(uri, range) {
118
+ return { uri: uri, range: range };
119
+ }
120
+ Location.create = create;
121
+ /**
122
+ * Checks whether the given literal conforms to the {@link Location} interface.
123
+ */
124
+ function is(value) {
125
+ var candidate = value;
126
+ return Is.objectLiteral(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
127
+ }
128
+ Location.is = is;
129
+ })(Location || (exports.Location = Location = {}));
130
+ /**
131
+ * The LocationLink namespace provides helper functions to work with
132
+ * {@link LocationLink} literals.
133
+ */
134
+ var LocationLink;
135
+ (function (LocationLink) {
136
+ /**
137
+ * Creates a LocationLink literal.
138
+ * @param targetUri The definition's uri.
139
+ * @param targetRange The full range of the definition.
140
+ * @param targetSelectionRange The span of the symbol definition at the target.
141
+ * @param originSelectionRange The span of the symbol being defined in the originating source file.
142
+ */
143
+ function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) {
144
+ return { targetUri: targetUri, targetRange: targetRange, targetSelectionRange: targetSelectionRange, originSelectionRange: originSelectionRange };
145
+ }
146
+ LocationLink.create = create;
147
+ /**
148
+ * Checks whether the given literal conforms to the {@link LocationLink} interface.
149
+ */
150
+ function is(value) {
151
+ var candidate = value;
152
+ return Is.objectLiteral(candidate) && Range.is(candidate.targetRange) && Is.string(candidate.targetUri)
153
+ && Range.is(candidate.targetSelectionRange)
154
+ && (Range.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));
155
+ }
156
+ LocationLink.is = is;
157
+ })(LocationLink || (exports.LocationLink = LocationLink = {}));
158
+ /**
159
+ * The Color namespace provides helper functions to work with
160
+ * {@link Color} literals.
161
+ */
162
+ var Color;
163
+ (function (Color) {
164
+ /**
165
+ * Creates a new Color literal.
166
+ */
167
+ function create(red, green, blue, alpha) {
168
+ return {
169
+ red: red,
170
+ green: green,
171
+ blue: blue,
172
+ alpha: alpha,
173
+ };
174
+ }
175
+ Color.create = create;
176
+ /**
177
+ * Checks whether the given literal conforms to the {@link Color} interface.
178
+ */
179
+ function is(value) {
180
+ var candidate = value;
181
+ return Is.objectLiteral(candidate) && Is.numberRange(candidate.red, 0, 1)
182
+ && Is.numberRange(candidate.green, 0, 1)
183
+ && Is.numberRange(candidate.blue, 0, 1)
184
+ && Is.numberRange(candidate.alpha, 0, 1);
185
+ }
186
+ Color.is = is;
187
+ })(Color || (exports.Color = Color = {}));
188
+ /**
189
+ * The ColorInformation namespace provides helper functions to work with
190
+ * {@link ColorInformation} literals.
191
+ */
192
+ var ColorInformation;
193
+ (function (ColorInformation) {
194
+ /**
195
+ * Creates a new ColorInformation literal.
196
+ */
197
+ function create(range, color) {
198
+ return {
199
+ range: range,
200
+ color: color,
201
+ };
202
+ }
203
+ ColorInformation.create = create;
204
+ /**
205
+ * Checks whether the given literal conforms to the {@link ColorInformation} interface.
206
+ */
207
+ function is(value) {
208
+ var candidate = value;
209
+ return Is.objectLiteral(candidate) && Range.is(candidate.range) && Color.is(candidate.color);
210
+ }
211
+ ColorInformation.is = is;
212
+ })(ColorInformation || (exports.ColorInformation = ColorInformation = {}));
213
+ /**
214
+ * The Color namespace provides helper functions to work with
215
+ * {@link ColorPresentation} literals.
216
+ */
217
+ var ColorPresentation;
218
+ (function (ColorPresentation) {
219
+ /**
220
+ * Creates a new ColorInformation literal.
221
+ */
222
+ function create(label, textEdit, additionalTextEdits) {
223
+ return {
224
+ label: label,
225
+ textEdit: textEdit,
226
+ additionalTextEdits: additionalTextEdits,
227
+ };
228
+ }
229
+ ColorPresentation.create = create;
230
+ /**
231
+ * Checks whether the given literal conforms to the {@link ColorInformation} interface.
232
+ */
233
+ function is(value) {
234
+ var candidate = value;
235
+ return Is.objectLiteral(candidate) && Is.string(candidate.label)
236
+ && (Is.undefined(candidate.textEdit) || TextEdit.is(candidate))
237
+ && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit.is));
238
+ }
239
+ ColorPresentation.is = is;
240
+ })(ColorPresentation || (exports.ColorPresentation = ColorPresentation = {}));
241
+ /**
242
+ * A set of predefined range kinds.
243
+ */
244
+ var FoldingRangeKind;
245
+ (function (FoldingRangeKind) {
246
+ /**
247
+ * Folding range for a comment
248
+ */
249
+ FoldingRangeKind.Comment = 'comment';
250
+ /**
251
+ * Folding range for an import or include
252
+ */
253
+ FoldingRangeKind.Imports = 'imports';
254
+ /**
255
+ * Folding range for a region (e.g. `#region`)
256
+ */
257
+ FoldingRangeKind.Region = 'region';
258
+ })(FoldingRangeKind || (exports.FoldingRangeKind = FoldingRangeKind = {}));
259
+ /**
260
+ * The folding range namespace provides helper functions to work with
261
+ * {@link FoldingRange} literals.
262
+ */
263
+ var FoldingRange;
264
+ (function (FoldingRange) {
265
+ /**
266
+ * Creates a new FoldingRange literal.
267
+ */
268
+ function create(startLine, endLine, startCharacter, endCharacter, kind, collapsedText) {
269
+ var result = {
270
+ startLine: startLine,
271
+ endLine: endLine
272
+ };
273
+ if (Is.defined(startCharacter)) {
274
+ result.startCharacter = startCharacter;
275
+ }
276
+ if (Is.defined(endCharacter)) {
277
+ result.endCharacter = endCharacter;
278
+ }
279
+ if (Is.defined(kind)) {
280
+ result.kind = kind;
281
+ }
282
+ if (Is.defined(collapsedText)) {
283
+ result.collapsedText = collapsedText;
284
+ }
285
+ return result;
286
+ }
287
+ FoldingRange.create = create;
288
+ /**
289
+ * Checks whether the given literal conforms to the {@link FoldingRange} interface.
290
+ */
291
+ function is(value) {
292
+ var candidate = value;
293
+ return Is.objectLiteral(candidate) && Is.uinteger(candidate.startLine) && Is.uinteger(candidate.startLine)
294
+ && (Is.undefined(candidate.startCharacter) || Is.uinteger(candidate.startCharacter))
295
+ && (Is.undefined(candidate.endCharacter) || Is.uinteger(candidate.endCharacter))
296
+ && (Is.undefined(candidate.kind) || Is.string(candidate.kind));
297
+ }
298
+ FoldingRange.is = is;
299
+ })(FoldingRange || (exports.FoldingRange = FoldingRange = {}));
300
+ /**
301
+ * The DiagnosticRelatedInformation namespace provides helper functions to work with
302
+ * {@link DiagnosticRelatedInformation} literals.
303
+ */
304
+ var DiagnosticRelatedInformation;
305
+ (function (DiagnosticRelatedInformation) {
306
+ /**
307
+ * Creates a new DiagnosticRelatedInformation literal.
308
+ */
309
+ function create(location, message) {
310
+ return {
311
+ location: location,
312
+ message: message
313
+ };
314
+ }
315
+ DiagnosticRelatedInformation.create = create;
316
+ /**
317
+ * Checks whether the given literal conforms to the {@link DiagnosticRelatedInformation} interface.
318
+ */
319
+ function is(value) {
320
+ var candidate = value;
321
+ return Is.defined(candidate) && Location.is(candidate.location) && Is.string(candidate.message);
322
+ }
323
+ DiagnosticRelatedInformation.is = is;
324
+ })(DiagnosticRelatedInformation || (exports.DiagnosticRelatedInformation = DiagnosticRelatedInformation = {}));
325
+ /**
326
+ * The diagnostic's severity.
327
+ */
328
+ var DiagnosticSeverity;
329
+ (function (DiagnosticSeverity) {
330
+ /**
331
+ * Reports an error.
332
+ */
333
+ DiagnosticSeverity.Error = 1;
334
+ /**
335
+ * Reports a warning.
336
+ */
337
+ DiagnosticSeverity.Warning = 2;
338
+ /**
339
+ * Reports an information.
340
+ */
341
+ DiagnosticSeverity.Information = 3;
342
+ /**
343
+ * Reports a hint.
344
+ */
345
+ DiagnosticSeverity.Hint = 4;
346
+ })(DiagnosticSeverity || (exports.DiagnosticSeverity = DiagnosticSeverity = {}));
347
+ /**
348
+ * The diagnostic tags.
349
+ *
350
+ * @since 3.15.0
351
+ */
352
+ var DiagnosticTag;
353
+ (function (DiagnosticTag) {
354
+ /**
355
+ * Unused or unnecessary code.
356
+ *
357
+ * Clients are allowed to render diagnostics with this tag faded out instead of having
358
+ * an error squiggle.
359
+ */
360
+ DiagnosticTag.Unnecessary = 1;
361
+ /**
362
+ * Deprecated or obsolete code.
363
+ *
364
+ * Clients are allowed to rendered diagnostics with this tag strike through.
365
+ */
366
+ DiagnosticTag.Deprecated = 2;
367
+ })(DiagnosticTag || (exports.DiagnosticTag = DiagnosticTag = {}));
368
+ /**
369
+ * The CodeDescription namespace provides functions to deal with descriptions for diagnostic codes.
370
+ *
371
+ * @since 3.16.0
372
+ */
373
+ var CodeDescription;
374
+ (function (CodeDescription) {
375
+ function is(value) {
376
+ var candidate = value;
377
+ return Is.objectLiteral(candidate) && Is.string(candidate.href);
378
+ }
379
+ CodeDescription.is = is;
380
+ })(CodeDescription || (exports.CodeDescription = CodeDescription = {}));
381
+ /**
382
+ * The Diagnostic namespace provides helper functions to work with
383
+ * {@link Diagnostic} literals.
384
+ */
385
+ var Diagnostic;
386
+ (function (Diagnostic) {
387
+ /**
388
+ * Creates a new Diagnostic literal.
389
+ */
390
+ function create(range, message, severity, code, source, relatedInformation) {
391
+ var result = { range: range, message: message };
392
+ if (Is.defined(severity)) {
393
+ result.severity = severity;
394
+ }
395
+ if (Is.defined(code)) {
396
+ result.code = code;
397
+ }
398
+ if (Is.defined(source)) {
399
+ result.source = source;
400
+ }
401
+ if (Is.defined(relatedInformation)) {
402
+ result.relatedInformation = relatedInformation;
403
+ }
404
+ return result;
405
+ }
406
+ Diagnostic.create = create;
407
+ /**
408
+ * Checks whether the given literal conforms to the {@link Diagnostic} interface.
409
+ */
410
+ function is(value) {
411
+ var _a;
412
+ var candidate = value;
413
+ return Is.defined(candidate)
414
+ && Range.is(candidate.range)
415
+ && (Is.string(candidate.message) || MarkupContent.is(candidate.message))
416
+ && (Is.number(candidate.severity) || Is.undefined(candidate.severity))
417
+ && (Is.integer(candidate.code) || Is.string(candidate.code) || Is.undefined(candidate.code))
418
+ && (Is.undefined(candidate.codeDescription) || (Is.string((_a = candidate.codeDescription) === null || _a === void 0 ? void 0 : _a.href)))
419
+ && (Is.string(candidate.source) || Is.undefined(candidate.source))
420
+ && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is));
421
+ }
422
+ Diagnostic.is = is;
423
+ /**
424
+ * Checks whether the given diagnostic's message conforms to the 3.17.0
425
+ * version of the protocol where the message is a string.
426
+ *
427
+ * @param value the diagnostic
428
+ * @returns true if the diagnostic's message is a string, false otherwise.
429
+ */
430
+ function is3_17(value) {
431
+ return Is.string(value.message);
432
+ }
433
+ Diagnostic.is3_17 = is3_17;
434
+ /**
435
+ * Gets the message string of a diagnostic. If the message is already a
436
+ * string, it is returned as is. If the message is a MarkupContent,
437
+ * the value of the MarkupContent is returned. Otherwise an error is thrown.
438
+ *
439
+ * @param diagnostic the diagnostic to get the message string from.
440
+ * @returns the message string of the given diagnostic.
441
+ */
442
+ function getMessageString(diagnostic) {
443
+ if (Is.string(diagnostic.message)) {
444
+ return diagnostic.message;
445
+ }
446
+ else if (MarkupContent.is(diagnostic.message)) {
447
+ return diagnostic.message.value;
448
+ }
449
+ else {
450
+ throw new Error("Unknown message type ".concat(typeof diagnostic.message));
451
+ }
452
+ }
453
+ Diagnostic.getMessageString = getMessageString;
454
+ })(Diagnostic || (exports.Diagnostic = Diagnostic = {}));
455
+ /**
456
+ * The Command namespace provides helper functions to work with
457
+ * {@link Command} literals.
458
+ */
459
+ var Command;
460
+ (function (Command) {
461
+ /**
462
+ * Creates a new Command literal.
463
+ */
464
+ function create(title, command) {
465
+ var args = [];
466
+ for (var _i = 2; _i < arguments.length; _i++) {
467
+ args[_i - 2] = arguments[_i];
468
+ }
469
+ var result = { title: title, command: command };
470
+ if (Is.defined(args) && args.length > 0) {
471
+ result.arguments = args;
472
+ }
473
+ return result;
474
+ }
475
+ Command.create = create;
476
+ /**
477
+ * Checks whether the given literal conforms to the {@link Command} interface.
478
+ */
479
+ function is(value) {
480
+ var candidate = value;
481
+ return Is.defined(candidate) && Is.string(candidate.title) && (candidate.tooltip === undefined || Is.string(candidate.tooltip)) && Is.string(candidate.command);
482
+ }
483
+ Command.is = is;
484
+ })(Command || (exports.Command = Command = {}));
485
+ /**
486
+ * The TextEdit namespace provides helper function to create replace,
487
+ * insert and delete edits more easily.
488
+ */
489
+ var TextEdit;
490
+ (function (TextEdit) {
491
+ /**
492
+ * Creates a replace text edit.
493
+ * @param range The range of text to be replaced.
494
+ * @param newText The new text.
495
+ */
496
+ function replace(range, newText) {
497
+ return { range: range, newText: newText };
498
+ }
499
+ TextEdit.replace = replace;
500
+ /**
501
+ * Creates an insert text edit.
502
+ * @param position The position to insert the text at.
503
+ * @param newText The text to be inserted.
504
+ */
505
+ function insert(position, newText) {
506
+ return { range: { start: position, end: position }, newText: newText };
507
+ }
508
+ TextEdit.insert = insert;
509
+ /**
510
+ * Creates a delete text edit.
511
+ * @param range The range of text to be deleted.
512
+ */
513
+ function del(range) {
514
+ return { range: range, newText: '' };
515
+ }
516
+ TextEdit.del = del;
517
+ function is(value) {
518
+ var candidate = value;
519
+ return Is.objectLiteral(candidate)
520
+ && Is.string(candidate.newText)
521
+ && Range.is(candidate.range);
522
+ }
523
+ TextEdit.is = is;
524
+ })(TextEdit || (exports.TextEdit = TextEdit = {}));
525
+ var ChangeAnnotation;
526
+ (function (ChangeAnnotation) {
527
+ function create(label, needsConfirmation, description) {
528
+ var result = { label: label };
529
+ if (needsConfirmation !== undefined) {
530
+ result.needsConfirmation = needsConfirmation;
531
+ }
532
+ if (description !== undefined) {
533
+ result.description = description;
534
+ }
535
+ return result;
536
+ }
537
+ ChangeAnnotation.create = create;
538
+ function is(value) {
539
+ var candidate = value;
540
+ return Is.objectLiteral(candidate) && Is.string(candidate.label) &&
541
+ (Is.boolean(candidate.needsConfirmation) || candidate.needsConfirmation === undefined) &&
542
+ (Is.string(candidate.description) || candidate.description === undefined);
543
+ }
544
+ ChangeAnnotation.is = is;
545
+ })(ChangeAnnotation || (exports.ChangeAnnotation = ChangeAnnotation = {}));
546
+ var ChangeAnnotationIdentifier;
547
+ (function (ChangeAnnotationIdentifier) {
548
+ function is(value) {
549
+ var candidate = value;
550
+ return Is.string(candidate);
551
+ }
552
+ ChangeAnnotationIdentifier.is = is;
553
+ })(ChangeAnnotationIdentifier || (exports.ChangeAnnotationIdentifier = ChangeAnnotationIdentifier = {}));
554
+ var AnnotatedTextEdit;
555
+ (function (AnnotatedTextEdit) {
556
+ /**
557
+ * Creates an annotated replace text edit.
558
+ *
559
+ * @param range The range of text to be replaced.
560
+ * @param newText The new text.
561
+ * @param annotation The annotation.
562
+ */
563
+ function replace(range, newText, annotation) {
564
+ return { range: range, newText: newText, annotationId: annotation };
565
+ }
566
+ AnnotatedTextEdit.replace = replace;
567
+ /**
568
+ * Creates an annotated insert text edit.
569
+ *
570
+ * @param position The position to insert the text at.
571
+ * @param newText The text to be inserted.
572
+ * @param annotation The annotation.
573
+ */
574
+ function insert(position, newText, annotation) {
575
+ return { range: { start: position, end: position }, newText: newText, annotationId: annotation };
576
+ }
577
+ AnnotatedTextEdit.insert = insert;
578
+ /**
579
+ * Creates an annotated delete text edit.
580
+ *
581
+ * @param range The range of text to be deleted.
582
+ * @param annotation The annotation.
583
+ */
584
+ function del(range, annotation) {
585
+ return { range: range, newText: '', annotationId: annotation };
586
+ }
587
+ AnnotatedTextEdit.del = del;
588
+ function is(value) {
589
+ var candidate = value;
590
+ return TextEdit.is(candidate) && (ChangeAnnotation.is(candidate.annotationId) || ChangeAnnotationIdentifier.is(candidate.annotationId));
591
+ }
592
+ AnnotatedTextEdit.is = is;
593
+ })(AnnotatedTextEdit || (exports.AnnotatedTextEdit = AnnotatedTextEdit = {}));
594
+ /**
595
+ * The TextDocumentEdit namespace provides helper function to create
596
+ * an edit that manipulates a text document.
597
+ */
598
+ var TextDocumentEdit;
599
+ (function (TextDocumentEdit) {
600
+ /**
601
+ * Creates a new `TextDocumentEdit`
602
+ */
603
+ function create(textDocument, edits) {
604
+ return { textDocument: textDocument, edits: edits };
605
+ }
606
+ TextDocumentEdit.create = create;
607
+ function is(value) {
608
+ var candidate = value;
609
+ return Is.defined(candidate)
610
+ && OptionalVersionedTextDocumentIdentifier.is(candidate.textDocument)
611
+ && Array.isArray(candidate.edits);
612
+ }
613
+ TextDocumentEdit.is = is;
614
+ })(TextDocumentEdit || (exports.TextDocumentEdit = TextDocumentEdit = {}));
615
+ var CreateFile;
616
+ (function (CreateFile) {
617
+ function create(uri, options, annotation) {
618
+ var result = {
619
+ kind: 'create',
620
+ uri: uri
621
+ };
622
+ if (options !== undefined && (options.overwrite !== undefined || options.ignoreIfExists !== undefined)) {
623
+ result.options = options;
624
+ }
625
+ if (annotation !== undefined) {
626
+ result.annotationId = annotation;
627
+ }
628
+ return result;
629
+ }
630
+ CreateFile.create = create;
631
+ function is(value) {
632
+ var candidate = value;
633
+ return candidate && candidate.kind === 'create' && Is.string(candidate.uri) && (candidate.options === undefined ||
634
+ ((candidate.options.overwrite === undefined || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === undefined || Is.boolean(candidate.options.ignoreIfExists)))) && (candidate.annotationId === undefined || ChangeAnnotationIdentifier.is(candidate.annotationId));
635
+ }
636
+ CreateFile.is = is;
637
+ })(CreateFile || (exports.CreateFile = CreateFile = {}));
638
+ var RenameFile;
639
+ (function (RenameFile) {
640
+ function create(oldUri, newUri, options, annotation) {
641
+ var result = {
642
+ kind: 'rename',
643
+ oldUri: oldUri,
644
+ newUri: newUri
645
+ };
646
+ if (options !== undefined && (options.overwrite !== undefined || options.ignoreIfExists !== undefined)) {
647
+ result.options = options;
648
+ }
649
+ if (annotation !== undefined) {
650
+ result.annotationId = annotation;
651
+ }
652
+ return result;
653
+ }
654
+ RenameFile.create = create;
655
+ function is(value) {
656
+ var candidate = value;
657
+ return candidate && candidate.kind === 'rename' && Is.string(candidate.oldUri) && Is.string(candidate.newUri) && (candidate.options === undefined ||
658
+ ((candidate.options.overwrite === undefined || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === undefined || Is.boolean(candidate.options.ignoreIfExists)))) && (candidate.annotationId === undefined || ChangeAnnotationIdentifier.is(candidate.annotationId));
659
+ }
660
+ RenameFile.is = is;
661
+ })(RenameFile || (exports.RenameFile = RenameFile = {}));
662
+ var DeleteFile;
663
+ (function (DeleteFile) {
664
+ function create(uri, options, annotation) {
665
+ var result = {
666
+ kind: 'delete',
667
+ uri: uri
668
+ };
669
+ if (options !== undefined && (options.recursive !== undefined || options.ignoreIfNotExists !== undefined)) {
670
+ result.options = options;
671
+ }
672
+ if (annotation !== undefined) {
673
+ result.annotationId = annotation;
674
+ }
675
+ return result;
676
+ }
677
+ DeleteFile.create = create;
678
+ function is(value) {
679
+ var candidate = value;
680
+ return candidate && candidate.kind === 'delete' && Is.string(candidate.uri) && (candidate.options === undefined ||
681
+ ((candidate.options.recursive === undefined || Is.boolean(candidate.options.recursive)) && (candidate.options.ignoreIfNotExists === undefined || Is.boolean(candidate.options.ignoreIfNotExists)))) && (candidate.annotationId === undefined || ChangeAnnotationIdentifier.is(candidate.annotationId));
682
+ }
683
+ DeleteFile.is = is;
684
+ })(DeleteFile || (exports.DeleteFile = DeleteFile = {}));
685
+ var WorkspaceEdit;
686
+ (function (WorkspaceEdit) {
687
+ function is(value) {
688
+ var candidate = value;
689
+ return candidate &&
690
+ (candidate.changes !== undefined || candidate.documentChanges !== undefined) &&
691
+ (candidate.documentChanges === undefined || candidate.documentChanges.every(function (change) {
692
+ if (Is.string(change.kind)) {
693
+ return CreateFile.is(change) || RenameFile.is(change) || DeleteFile.is(change);
694
+ }
695
+ else {
696
+ return TextDocumentEdit.is(change);
697
+ }
698
+ }));
699
+ }
700
+ WorkspaceEdit.is = is;
701
+ })(WorkspaceEdit || (exports.WorkspaceEdit = WorkspaceEdit = {}));
702
+ var TextEditChangeImpl = /** @class */ (function () {
703
+ function TextEditChangeImpl(edits, changeAnnotations) {
704
+ this.edits = edits;
705
+ this.changeAnnotations = changeAnnotations;
706
+ }
707
+ TextEditChangeImpl.prototype.insert = function (position, newText, annotation) {
708
+ var edit;
709
+ var id;
710
+ if (annotation === undefined) {
711
+ edit = TextEdit.insert(position, newText);
712
+ }
713
+ else if (ChangeAnnotationIdentifier.is(annotation)) {
714
+ id = annotation;
715
+ edit = AnnotatedTextEdit.insert(position, newText, annotation);
716
+ }
717
+ else {
718
+ this.assertChangeAnnotations(this.changeAnnotations);
719
+ id = this.changeAnnotations.manage(annotation);
720
+ edit = AnnotatedTextEdit.insert(position, newText, id);
721
+ }
722
+ this.edits.push(edit);
723
+ if (id !== undefined) {
724
+ return id;
725
+ }
726
+ };
727
+ TextEditChangeImpl.prototype.replace = function (range, newText, annotation) {
728
+ var edit;
729
+ var id;
730
+ if (annotation === undefined) {
731
+ edit = TextEdit.replace(range, newText);
732
+ }
733
+ else if (ChangeAnnotationIdentifier.is(annotation)) {
734
+ id = annotation;
735
+ edit = AnnotatedTextEdit.replace(range, newText, annotation);
736
+ }
737
+ else {
738
+ this.assertChangeAnnotations(this.changeAnnotations);
739
+ id = this.changeAnnotations.manage(annotation);
740
+ edit = AnnotatedTextEdit.replace(range, newText, id);
741
+ }
742
+ this.edits.push(edit);
743
+ if (id !== undefined) {
744
+ return id;
745
+ }
746
+ };
747
+ TextEditChangeImpl.prototype.delete = function (range, annotation) {
748
+ var edit;
749
+ var id;
750
+ if (annotation === undefined) {
751
+ edit = TextEdit.del(range);
752
+ }
753
+ else if (ChangeAnnotationIdentifier.is(annotation)) {
754
+ id = annotation;
755
+ edit = AnnotatedTextEdit.del(range, annotation);
756
+ }
757
+ else {
758
+ this.assertChangeAnnotations(this.changeAnnotations);
759
+ id = this.changeAnnotations.manage(annotation);
760
+ edit = AnnotatedTextEdit.del(range, id);
761
+ }
762
+ this.edits.push(edit);
763
+ if (id !== undefined) {
764
+ return id;
765
+ }
766
+ };
767
+ TextEditChangeImpl.prototype.add = function (edit) {
768
+ this.edits.push(edit);
769
+ };
770
+ TextEditChangeImpl.prototype.all = function () {
771
+ return this.edits;
772
+ };
773
+ TextEditChangeImpl.prototype.clear = function () {
774
+ this.edits.splice(0, this.edits.length);
775
+ };
776
+ TextEditChangeImpl.prototype.assertChangeAnnotations = function (value) {
777
+ if (value === undefined) {
778
+ throw new Error("Text edit change is not configured to manage change annotations.");
779
+ }
780
+ };
781
+ return TextEditChangeImpl;
782
+ }());
783
+ var SnippetTextEdit;
784
+ (function (SnippetTextEdit) {
785
+ function is(value) {
786
+ var candidate = value;
787
+ return Is.objectLiteral(candidate)
788
+ && Range.is(candidate.range)
789
+ && StringValue.isSnippet(candidate.snippet)
790
+ && (candidate.annotationId === undefined ||
791
+ (ChangeAnnotation.is(candidate.annotationId) || ChangeAnnotationIdentifier.is(candidate.annotationId)));
792
+ }
793
+ SnippetTextEdit.is = is;
794
+ })(SnippetTextEdit || (exports.SnippetTextEdit = SnippetTextEdit = {}));
795
+ /**
796
+ * A helper class
797
+ */
798
+ var ChangeAnnotations = /** @class */ (function () {
799
+ function ChangeAnnotations(annotations) {
800
+ this._annotations = annotations === undefined ? Object.create(null) : annotations;
801
+ this._counter = 0;
802
+ this._size = 0;
803
+ }
804
+ ChangeAnnotations.prototype.all = function () {
805
+ return this._annotations;
806
+ };
807
+ Object.defineProperty(ChangeAnnotations.prototype, "size", {
808
+ get: function () {
809
+ return this._size;
810
+ },
811
+ enumerable: false,
812
+ configurable: true
813
+ });
814
+ ChangeAnnotations.prototype.manage = function (idOrAnnotation, annotation) {
815
+ var id;
816
+ if (ChangeAnnotationIdentifier.is(idOrAnnotation)) {
817
+ id = idOrAnnotation;
818
+ }
819
+ else {
820
+ id = this.nextId();
821
+ annotation = idOrAnnotation;
822
+ }
823
+ if (this._annotations[id] !== undefined) {
824
+ throw new Error("Id ".concat(id, " is already in use."));
825
+ }
826
+ if (annotation === undefined) {
827
+ throw new Error("No annotation provided for id ".concat(id));
828
+ }
829
+ this._annotations[id] = annotation;
830
+ this._size++;
831
+ return id;
832
+ };
833
+ ChangeAnnotations.prototype.nextId = function () {
834
+ this._counter++;
835
+ return this._counter.toString();
836
+ };
837
+ return ChangeAnnotations;
838
+ }());
839
+ /**
840
+ * A workspace change helps constructing changes to a workspace.
841
+ */
842
+ var WorkspaceChange = /** @class */ (function () {
843
+ function WorkspaceChange(workspaceEdit) {
844
+ var _this = this;
845
+ this._textEditChanges = Object.create(null);
846
+ if (workspaceEdit !== undefined) {
847
+ this._workspaceEdit = workspaceEdit;
848
+ if (workspaceEdit.documentChanges) {
849
+ this._changeAnnotations = new ChangeAnnotations(workspaceEdit.changeAnnotations);
850
+ workspaceEdit.changeAnnotations = this._changeAnnotations.all();
851
+ workspaceEdit.documentChanges.forEach(function (change) {
852
+ if (TextDocumentEdit.is(change)) {
853
+ var textEditChange = new TextEditChangeImpl(change.edits, _this._changeAnnotations);
854
+ _this._textEditChanges[change.textDocument.uri] = textEditChange;
855
+ }
856
+ });
857
+ }
858
+ else if (workspaceEdit.changes) {
859
+ Object.keys(workspaceEdit.changes).forEach(function (key) {
860
+ var textEditChange = new TextEditChangeImpl(workspaceEdit.changes[key]);
861
+ _this._textEditChanges[key] = textEditChange;
862
+ });
863
+ }
864
+ }
865
+ else {
866
+ this._workspaceEdit = {};
867
+ }
868
+ }
869
+ Object.defineProperty(WorkspaceChange.prototype, "edit", {
870
+ /**
871
+ * Returns the underlying {@link WorkspaceEdit} literal
872
+ * use to be returned from a workspace edit operation like rename.
873
+ */
874
+ get: function () {
875
+ this.initDocumentChanges();
876
+ if (this._changeAnnotations !== undefined) {
877
+ if (this._changeAnnotations.size === 0) {
878
+ this._workspaceEdit.changeAnnotations = undefined;
879
+ }
880
+ else {
881
+ this._workspaceEdit.changeAnnotations = this._changeAnnotations.all();
882
+ }
883
+ }
884
+ return this._workspaceEdit;
885
+ },
886
+ enumerable: false,
887
+ configurable: true
888
+ });
889
+ WorkspaceChange.prototype.getTextEditChange = function (key) {
890
+ if (OptionalVersionedTextDocumentIdentifier.is(key)) {
891
+ this.initDocumentChanges();
892
+ if (this._workspaceEdit.documentChanges === undefined) {
893
+ throw new Error('Workspace edit is not configured for document changes.');
894
+ }
895
+ var textDocument = { uri: key.uri, version: key.version };
896
+ var result = this._textEditChanges[textDocument.uri];
897
+ if (!result) {
898
+ var edits = [];
899
+ var textDocumentEdit = {
900
+ textDocument: textDocument,
901
+ edits: edits
902
+ };
903
+ this._workspaceEdit.documentChanges.push(textDocumentEdit);
904
+ result = new TextEditChangeImpl(edits, this._changeAnnotations);
905
+ this._textEditChanges[textDocument.uri] = result;
906
+ }
907
+ return result;
908
+ }
909
+ else {
910
+ this.initChanges();
911
+ if (this._workspaceEdit.changes === undefined) {
912
+ throw new Error('Workspace edit is not configured for normal text edit changes.');
913
+ }
914
+ var result = this._textEditChanges[key];
915
+ if (!result) {
916
+ var edits = [];
917
+ this._workspaceEdit.changes[key] = edits;
918
+ result = new TextEditChangeImpl(edits);
919
+ this._textEditChanges[key] = result;
920
+ }
921
+ return result;
922
+ }
923
+ };
924
+ WorkspaceChange.prototype.initDocumentChanges = function () {
925
+ if (this._workspaceEdit.documentChanges === undefined && this._workspaceEdit.changes === undefined) {
926
+ this._changeAnnotations = new ChangeAnnotations();
927
+ this._workspaceEdit.documentChanges = [];
928
+ this._workspaceEdit.changeAnnotations = this._changeAnnotations.all();
929
+ }
930
+ };
931
+ WorkspaceChange.prototype.initChanges = function () {
932
+ if (this._workspaceEdit.documentChanges === undefined && this._workspaceEdit.changes === undefined) {
933
+ this._workspaceEdit.changes = Object.create(null);
934
+ }
935
+ };
936
+ WorkspaceChange.prototype.createFile = function (uri, optionsOrAnnotation, options) {
937
+ this.initDocumentChanges();
938
+ if (this._workspaceEdit.documentChanges === undefined) {
939
+ throw new Error('Workspace edit is not configured for document changes.');
940
+ }
941
+ var annotation;
942
+ if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) {
943
+ annotation = optionsOrAnnotation;
944
+ }
945
+ else {
946
+ options = optionsOrAnnotation;
947
+ }
948
+ var operation;
949
+ var id;
950
+ if (annotation === undefined) {
951
+ operation = CreateFile.create(uri, options);
952
+ }
953
+ else {
954
+ id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation);
955
+ operation = CreateFile.create(uri, options, id);
956
+ }
957
+ this._workspaceEdit.documentChanges.push(operation);
958
+ if (id !== undefined) {
959
+ return id;
960
+ }
961
+ };
962
+ WorkspaceChange.prototype.renameFile = function (oldUri, newUri, optionsOrAnnotation, options) {
963
+ this.initDocumentChanges();
964
+ if (this._workspaceEdit.documentChanges === undefined) {
965
+ throw new Error('Workspace edit is not configured for document changes.');
966
+ }
967
+ var annotation;
968
+ if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) {
969
+ annotation = optionsOrAnnotation;
970
+ }
971
+ else {
972
+ options = optionsOrAnnotation;
973
+ }
974
+ var operation;
975
+ var id;
976
+ if (annotation === undefined) {
977
+ operation = RenameFile.create(oldUri, newUri, options);
978
+ }
979
+ else {
980
+ id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation);
981
+ operation = RenameFile.create(oldUri, newUri, options, id);
982
+ }
983
+ this._workspaceEdit.documentChanges.push(operation);
984
+ if (id !== undefined) {
985
+ return id;
986
+ }
987
+ };
988
+ WorkspaceChange.prototype.deleteFile = function (uri, optionsOrAnnotation, options) {
989
+ this.initDocumentChanges();
990
+ if (this._workspaceEdit.documentChanges === undefined) {
991
+ throw new Error('Workspace edit is not configured for document changes.');
992
+ }
993
+ var annotation;
994
+ if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) {
995
+ annotation = optionsOrAnnotation;
996
+ }
997
+ else {
998
+ options = optionsOrAnnotation;
999
+ }
1000
+ var operation;
1001
+ var id;
1002
+ if (annotation === undefined) {
1003
+ operation = DeleteFile.create(uri, options);
1004
+ }
1005
+ else {
1006
+ id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation);
1007
+ operation = DeleteFile.create(uri, options, id);
1008
+ }
1009
+ this._workspaceEdit.documentChanges.push(operation);
1010
+ if (id !== undefined) {
1011
+ return id;
1012
+ }
1013
+ };
1014
+ return WorkspaceChange;
1015
+ }());
1016
+ exports.WorkspaceChange = WorkspaceChange;
1017
+ /**
1018
+ * The TextDocumentIdentifier namespace provides helper functions to work with
1019
+ * {@link TextDocumentIdentifier} literals.
1020
+ */
1021
+ var TextDocumentIdentifier;
1022
+ (function (TextDocumentIdentifier) {
1023
+ /**
1024
+ * Creates a new TextDocumentIdentifier literal.
1025
+ * @param uri The document's uri.
1026
+ */
1027
+ function create(uri) {
1028
+ return { uri: uri };
1029
+ }
1030
+ TextDocumentIdentifier.create = create;
1031
+ /**
1032
+ * Checks whether the given literal conforms to the {@link TextDocumentIdentifier} interface.
1033
+ */
1034
+ function is(value) {
1035
+ var candidate = value;
1036
+ return Is.defined(candidate) && Is.string(candidate.uri);
1037
+ }
1038
+ TextDocumentIdentifier.is = is;
1039
+ })(TextDocumentIdentifier || (exports.TextDocumentIdentifier = TextDocumentIdentifier = {}));
1040
+ /**
1041
+ * The VersionedTextDocumentIdentifier namespace provides helper functions to work with
1042
+ * {@link VersionedTextDocumentIdentifier} literals.
1043
+ */
1044
+ var VersionedTextDocumentIdentifier;
1045
+ (function (VersionedTextDocumentIdentifier) {
1046
+ /**
1047
+ * Creates a new VersionedTextDocumentIdentifier literal.
1048
+ * @param uri The document's uri.
1049
+ * @param version The document's version.
1050
+ */
1051
+ function create(uri, version) {
1052
+ return { uri: uri, version: version };
1053
+ }
1054
+ VersionedTextDocumentIdentifier.create = create;
1055
+ /**
1056
+ * Checks whether the given literal conforms to the {@link VersionedTextDocumentIdentifier} interface.
1057
+ */
1058
+ function is(value) {
1059
+ var candidate = value;
1060
+ return Is.defined(candidate) && Is.string(candidate.uri) && Is.integer(candidate.version);
1061
+ }
1062
+ VersionedTextDocumentIdentifier.is = is;
1063
+ })(VersionedTextDocumentIdentifier || (exports.VersionedTextDocumentIdentifier = VersionedTextDocumentIdentifier = {}));
1064
+ /**
1065
+ * The OptionalVersionedTextDocumentIdentifier namespace provides helper functions to work with
1066
+ * {@link OptionalVersionedTextDocumentIdentifier} literals.
1067
+ */
1068
+ var OptionalVersionedTextDocumentIdentifier;
1069
+ (function (OptionalVersionedTextDocumentIdentifier) {
1070
+ /**
1071
+ * Creates a new OptionalVersionedTextDocumentIdentifier literal.
1072
+ * @param uri The document's uri.
1073
+ * @param version The document's version.
1074
+ */
1075
+ function create(uri, version) {
1076
+ return { uri: uri, version: version };
1077
+ }
1078
+ OptionalVersionedTextDocumentIdentifier.create = create;
1079
+ /**
1080
+ * Checks whether the given literal conforms to the {@link OptionalVersionedTextDocumentIdentifier} interface.
1081
+ */
1082
+ function is(value) {
1083
+ var candidate = value;
1084
+ return Is.defined(candidate) && Is.string(candidate.uri) && (candidate.version === null || Is.integer(candidate.version));
1085
+ }
1086
+ OptionalVersionedTextDocumentIdentifier.is = is;
1087
+ })(OptionalVersionedTextDocumentIdentifier || (exports.OptionalVersionedTextDocumentIdentifier = OptionalVersionedTextDocumentIdentifier = {}));
1088
+ /**
1089
+ * Predefined Language kinds
1090
+ * @since 3.18.0
1091
+ */
1092
+ var LanguageKind;
1093
+ (function (LanguageKind) {
1094
+ LanguageKind.ABAP = 'abap';
1095
+ LanguageKind.WindowsBat = 'bat';
1096
+ LanguageKind.BibTeX = 'bibtex';
1097
+ LanguageKind.Clojure = 'clojure';
1098
+ LanguageKind.Coffeescript = 'coffeescript';
1099
+ LanguageKind.C = 'c';
1100
+ LanguageKind.CPP = 'cpp';
1101
+ LanguageKind.CSharp = 'csharp';
1102
+ LanguageKind.CSS = 'css';
1103
+ /**
1104
+ * @since 3.18.0
1105
+ */
1106
+ LanguageKind.D = 'd';
1107
+ /**
1108
+ * @since 3.18.0
1109
+ */
1110
+ LanguageKind.Delphi = 'pascal';
1111
+ LanguageKind.Diff = 'diff';
1112
+ LanguageKind.Dart = 'dart';
1113
+ LanguageKind.Dockerfile = 'dockerfile';
1114
+ LanguageKind.Elixir = 'elixir';
1115
+ LanguageKind.Erlang = 'erlang';
1116
+ LanguageKind.FSharp = 'fsharp';
1117
+ LanguageKind.GitCommit = 'git-commit';
1118
+ LanguageKind.GitRebase = 'git-rebase';
1119
+ LanguageKind.Go = 'go';
1120
+ LanguageKind.Groovy = 'groovy';
1121
+ LanguageKind.Handlebars = 'handlebars';
1122
+ LanguageKind.Haskell = 'haskell';
1123
+ LanguageKind.HTML = 'html';
1124
+ LanguageKind.Ini = 'ini';
1125
+ LanguageKind.Java = 'java';
1126
+ LanguageKind.JavaScript = 'javascript';
1127
+ LanguageKind.JavaScriptReact = 'javascriptreact';
1128
+ LanguageKind.JSON = 'json';
1129
+ LanguageKind.LaTeX = 'latex';
1130
+ LanguageKind.Less = 'less';
1131
+ LanguageKind.Lua = 'lua';
1132
+ LanguageKind.Makefile = 'makefile';
1133
+ LanguageKind.Markdown = 'markdown';
1134
+ LanguageKind.ObjectiveC = 'objective-c';
1135
+ LanguageKind.ObjectiveCPP = 'objective-cpp';
1136
+ /**
1137
+ * @since 3.18.0
1138
+ */
1139
+ LanguageKind.Pascal = 'pascal';
1140
+ LanguageKind.Perl = 'perl';
1141
+ LanguageKind.Perl6 = 'perl6';
1142
+ LanguageKind.PHP = 'php';
1143
+ LanguageKind.Plaintext = 'plaintext';
1144
+ LanguageKind.Powershell = 'powershell';
1145
+ LanguageKind.Pug = 'jade';
1146
+ LanguageKind.Python = 'python';
1147
+ LanguageKind.R = 'r';
1148
+ LanguageKind.Razor = 'razor';
1149
+ LanguageKind.Ruby = 'ruby';
1150
+ LanguageKind.Rust = 'rust';
1151
+ LanguageKind.SCSS = 'scss';
1152
+ LanguageKind.SASS = 'sass';
1153
+ LanguageKind.Scala = 'scala';
1154
+ LanguageKind.ShaderLab = 'shaderlab';
1155
+ LanguageKind.ShellScript = 'shellscript';
1156
+ LanguageKind.SQL = 'sql';
1157
+ LanguageKind.Swift = 'swift';
1158
+ LanguageKind.TypeScript = 'typescript';
1159
+ LanguageKind.TypeScriptReact = 'typescriptreact';
1160
+ LanguageKind.TeX = 'tex';
1161
+ LanguageKind.VisualBasic = 'vb';
1162
+ LanguageKind.XML = 'xml';
1163
+ LanguageKind.XSL = 'xsl';
1164
+ LanguageKind.YAML = 'yaml';
1165
+ })(LanguageKind || (exports.LanguageKind = LanguageKind = {}));
1166
+ /**
1167
+ * The TextDocumentItem namespace provides helper functions to work with
1168
+ * {@link TextDocumentItem} literals.
1169
+ */
1170
+ var TextDocumentItem;
1171
+ (function (TextDocumentItem) {
1172
+ /**
1173
+ * Creates a new TextDocumentItem literal.
1174
+ * @param uri The document's uri.
1175
+ * @param languageId The document's language identifier.
1176
+ * @param version The document's version number.
1177
+ * @param text The document's text.
1178
+ */
1179
+ function create(uri, languageId, version, text) {
1180
+ return { uri: uri, languageId: languageId, version: version, text: text };
1181
+ }
1182
+ TextDocumentItem.create = create;
1183
+ /**
1184
+ * Checks whether the given literal conforms to the {@link TextDocumentItem} interface.
1185
+ */
1186
+ function is(value) {
1187
+ var candidate = value;
1188
+ return Is.defined(candidate) && Is.string(candidate.uri) && Is.string(candidate.languageId) && Is.integer(candidate.version) && Is.string(candidate.text);
1189
+ }
1190
+ TextDocumentItem.is = is;
1191
+ })(TextDocumentItem || (exports.TextDocumentItem = TextDocumentItem = {}));
1192
+ /**
1193
+ * Describes the content type that a client supports in various
1194
+ * result literals like `Hover`, `ParameterInfo` or `CompletionItem`.
1195
+ *
1196
+ * Please note that `MarkupKinds` must not start with a `$`. This kinds
1197
+ * are reserved for internal usage.
1198
+ */
1199
+ var MarkupKind;
1200
+ (function (MarkupKind) {
1201
+ /**
1202
+ * Plain text is supported as a content format
1203
+ */
1204
+ MarkupKind.PlainText = 'plaintext';
1205
+ /**
1206
+ * Markdown is supported as a content format
1207
+ */
1208
+ MarkupKind.Markdown = 'markdown';
1209
+ /**
1210
+ * Checks whether the given value is a value of the {@link MarkupKind} type.
1211
+ */
1212
+ function is(value) {
1213
+ var candidate = value;
1214
+ return candidate === MarkupKind.PlainText || candidate === MarkupKind.Markdown;
1215
+ }
1216
+ MarkupKind.is = is;
1217
+ })(MarkupKind || (exports.MarkupKind = MarkupKind = {}));
1218
+ var MarkupContent;
1219
+ (function (MarkupContent) {
1220
+ /**
1221
+ * Checks whether the given value conforms to the {@link MarkupContent} interface.
1222
+ */
1223
+ function is(value) {
1224
+ var candidate = value;
1225
+ return Is.objectLiteral(value) && MarkupKind.is(candidate.kind) && Is.string(candidate.value);
1226
+ }
1227
+ MarkupContent.is = is;
1228
+ })(MarkupContent || (exports.MarkupContent = MarkupContent = {}));
1229
+ /**
1230
+ * The kind of a completion entry.
1231
+ */
1232
+ var CompletionItemKind;
1233
+ (function (CompletionItemKind) {
1234
+ CompletionItemKind.Text = 1;
1235
+ CompletionItemKind.Method = 2;
1236
+ CompletionItemKind.Function = 3;
1237
+ CompletionItemKind.Constructor = 4;
1238
+ CompletionItemKind.Field = 5;
1239
+ CompletionItemKind.Variable = 6;
1240
+ CompletionItemKind.Class = 7;
1241
+ CompletionItemKind.Interface = 8;
1242
+ CompletionItemKind.Module = 9;
1243
+ CompletionItemKind.Property = 10;
1244
+ CompletionItemKind.Unit = 11;
1245
+ CompletionItemKind.Value = 12;
1246
+ CompletionItemKind.Enum = 13;
1247
+ CompletionItemKind.Keyword = 14;
1248
+ CompletionItemKind.Snippet = 15;
1249
+ CompletionItemKind.Color = 16;
1250
+ CompletionItemKind.File = 17;
1251
+ CompletionItemKind.Reference = 18;
1252
+ CompletionItemKind.Folder = 19;
1253
+ CompletionItemKind.EnumMember = 20;
1254
+ CompletionItemKind.Constant = 21;
1255
+ CompletionItemKind.Struct = 22;
1256
+ CompletionItemKind.Event = 23;
1257
+ CompletionItemKind.Operator = 24;
1258
+ CompletionItemKind.TypeParameter = 25;
1259
+ })(CompletionItemKind || (exports.CompletionItemKind = CompletionItemKind = {}));
1260
+ /**
1261
+ * Defines whether the insert text in a completion item should be interpreted as
1262
+ * plain text or a snippet.
1263
+ */
1264
+ var InsertTextFormat;
1265
+ (function (InsertTextFormat) {
1266
+ /**
1267
+ * The primary text to be inserted is treated as a plain string.
1268
+ */
1269
+ InsertTextFormat.PlainText = 1;
1270
+ /**
1271
+ * The primary text to be inserted is treated as a snippet.
1272
+ *
1273
+ * A snippet can define tab stops and placeholders with `$1`, `$2`
1274
+ * and `${3:foo}`. `$0` defines the final tab stop, it defaults to
1275
+ * the end of the snippet. Placeholders with equal identifiers are linked,
1276
+ * that is typing in one will update others too.
1277
+ *
1278
+ * See also: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#snippet_syntax
1279
+ */
1280
+ InsertTextFormat.Snippet = 2;
1281
+ })(InsertTextFormat || (exports.InsertTextFormat = InsertTextFormat = {}));
1282
+ /**
1283
+ * Completion item tags are extra annotations that tweak the rendering of a completion
1284
+ * item.
1285
+ *
1286
+ * @since 3.15.0
1287
+ */
1288
+ var CompletionItemTag;
1289
+ (function (CompletionItemTag) {
1290
+ /**
1291
+ * Render a completion as obsolete, usually using a strike-out.
1292
+ */
1293
+ CompletionItemTag.Deprecated = 1;
1294
+ })(CompletionItemTag || (exports.CompletionItemTag = CompletionItemTag = {}));
1295
+ /**
1296
+ * The InsertReplaceEdit namespace provides functions to deal with insert / replace edits.
1297
+ *
1298
+ * @since 3.16.0
1299
+ */
1300
+ var InsertReplaceEdit;
1301
+ (function (InsertReplaceEdit) {
1302
+ /**
1303
+ * Creates a new insert / replace edit
1304
+ */
1305
+ function create(newText, insert, replace) {
1306
+ return { newText: newText, insert: insert, replace: replace };
1307
+ }
1308
+ InsertReplaceEdit.create = create;
1309
+ /**
1310
+ * Checks whether the given literal conforms to the {@link InsertReplaceEdit} interface.
1311
+ */
1312
+ function is(value) {
1313
+ var candidate = value;
1314
+ return candidate && Is.string(candidate.newText) && Range.is(candidate.insert) && Range.is(candidate.replace);
1315
+ }
1316
+ InsertReplaceEdit.is = is;
1317
+ })(InsertReplaceEdit || (exports.InsertReplaceEdit = InsertReplaceEdit = {}));
1318
+ /**
1319
+ * How whitespace and indentation is handled during completion
1320
+ * item insertion.
1321
+ *
1322
+ * @since 3.16.0
1323
+ */
1324
+ var InsertTextMode;
1325
+ (function (InsertTextMode) {
1326
+ /**
1327
+ * The insertion or replace strings is taken as it is. If the
1328
+ * value is multi line the lines below the cursor will be
1329
+ * inserted using the indentation defined in the string value.
1330
+ * The client will not apply any kind of adjustments to the
1331
+ * string.
1332
+ */
1333
+ InsertTextMode.asIs = 1;
1334
+ /**
1335
+ * The editor adjusts leading whitespace of new lines so that
1336
+ * they match the indentation up to the cursor of the line for
1337
+ * which the item is accepted.
1338
+ *
1339
+ * Consider a line like this: <2tabs><cursor><3tabs>foo. Accepting a
1340
+ * multi line completion item is indented using 2 tabs and all
1341
+ * following lines inserted will be indented using 2 tabs as well.
1342
+ */
1343
+ InsertTextMode.adjustIndentation = 2;
1344
+ })(InsertTextMode || (exports.InsertTextMode = InsertTextMode = {}));
1345
+ /**
1346
+ * Defines how values from a set of defaults and an individual item will be
1347
+ * merged.
1348
+ *
1349
+ * @since 3.18.0
1350
+ */
1351
+ var ApplyKind;
1352
+ (function (ApplyKind) {
1353
+ /**
1354
+ * The value from the individual item (if provided and not `null`) will be
1355
+ * used instead of the default.
1356
+ */
1357
+ ApplyKind.Replace = 1;
1358
+ /**
1359
+ * The value from the item will be merged with the default.
1360
+ *
1361
+ * The specific rules for mergeing values are defined against each field
1362
+ * that supports merging.
1363
+ */
1364
+ ApplyKind.Merge = 2;
1365
+ })(ApplyKind || (exports.ApplyKind = ApplyKind = {}));
1366
+ var CompletionItemLabelDetails;
1367
+ (function (CompletionItemLabelDetails) {
1368
+ function is(value) {
1369
+ var candidate = value;
1370
+ return candidate && (Is.string(candidate.detail) || candidate.detail === undefined) &&
1371
+ (Is.string(candidate.description) || candidate.description === undefined);
1372
+ }
1373
+ CompletionItemLabelDetails.is = is;
1374
+ })(CompletionItemLabelDetails || (exports.CompletionItemLabelDetails = CompletionItemLabelDetails = {}));
1375
+ /**
1376
+ * The CompletionItem namespace provides functions to deal with
1377
+ * completion items.
1378
+ */
1379
+ var CompletionItem;
1380
+ (function (CompletionItem) {
1381
+ /**
1382
+ * Create a completion item and seed it with a label.
1383
+ * @param label The completion item's label
1384
+ */
1385
+ function create(label) {
1386
+ return { label: label };
1387
+ }
1388
+ CompletionItem.create = create;
1389
+ })(CompletionItem || (exports.CompletionItem = CompletionItem = {}));
1390
+ /**
1391
+ * The CompletionList namespace provides functions to deal with
1392
+ * completion lists.
1393
+ */
1394
+ var CompletionList;
1395
+ (function (CompletionList) {
1396
+ /**
1397
+ * Creates a new completion list.
1398
+ *
1399
+ * @param items The completion items.
1400
+ * @param isIncomplete The list is not complete.
1401
+ */
1402
+ function create(items, isIncomplete) {
1403
+ return { items: items ? items : [], isIncomplete: !!isIncomplete };
1404
+ }
1405
+ CompletionList.create = create;
1406
+ })(CompletionList || (exports.CompletionList = CompletionList = {}));
1407
+ var MarkedString;
1408
+ (function (MarkedString) {
1409
+ /**
1410
+ * Creates a marked string from plain text.
1411
+ *
1412
+ * @param plainText The plain text.
1413
+ */
1414
+ function fromPlainText(plainText) {
1415
+ return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&'); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
1416
+ }
1417
+ MarkedString.fromPlainText = fromPlainText;
1418
+ /**
1419
+ * Checks whether the given value conforms to the {@link MarkedString} type.
1420
+ */
1421
+ function is(value) {
1422
+ var candidate = value;
1423
+ return Is.string(candidate) || (Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value));
1424
+ }
1425
+ MarkedString.is = is;
1426
+ })(MarkedString || (exports.MarkedString = MarkedString = {}));
1427
+ var Hover;
1428
+ (function (Hover) {
1429
+ /**
1430
+ * Checks whether the given value conforms to the {@link Hover} interface.
1431
+ */
1432
+ function is(value) {
1433
+ var candidate = value;
1434
+ return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) ||
1435
+ MarkedString.is(candidate.contents) ||
1436
+ Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === undefined || Range.is(value.range));
1437
+ }
1438
+ Hover.is = is;
1439
+ })(Hover || (exports.Hover = Hover = {}));
1440
+ /**
1441
+ * The ParameterInformation namespace provides helper functions to work with
1442
+ * {@link ParameterInformation} literals.
1443
+ */
1444
+ var ParameterInformation;
1445
+ (function (ParameterInformation) {
1446
+ /**
1447
+ * Creates a new parameter information literal.
1448
+ *
1449
+ * @param label A label string.
1450
+ * @param documentation A doc string.
1451
+ */
1452
+ function create(label, documentation) {
1453
+ return documentation ? { label: label, documentation: documentation } : { label: label };
1454
+ }
1455
+ ParameterInformation.create = create;
1456
+ })(ParameterInformation || (exports.ParameterInformation = ParameterInformation = {}));
1457
+ /**
1458
+ * The SignatureInformation namespace provides helper functions to work with
1459
+ * {@link SignatureInformation} literals.
1460
+ */
1461
+ var SignatureInformation;
1462
+ (function (SignatureInformation) {
1463
+ function create(label, documentation) {
1464
+ var parameters = [];
1465
+ for (var _i = 2; _i < arguments.length; _i++) {
1466
+ parameters[_i - 2] = arguments[_i];
1467
+ }
1468
+ var result = { label: label };
1469
+ if (Is.defined(documentation)) {
1470
+ result.documentation = documentation;
1471
+ }
1472
+ if (Is.defined(parameters)) {
1473
+ result.parameters = parameters;
1474
+ }
1475
+ else {
1476
+ result.parameters = [];
1477
+ }
1478
+ return result;
1479
+ }
1480
+ SignatureInformation.create = create;
1481
+ })(SignatureInformation || (exports.SignatureInformation = SignatureInformation = {}));
1482
+ /**
1483
+ * A document highlight kind.
1484
+ */
1485
+ var DocumentHighlightKind;
1486
+ (function (DocumentHighlightKind) {
1487
+ /**
1488
+ * A textual occurrence.
1489
+ */
1490
+ DocumentHighlightKind.Text = 1;
1491
+ /**
1492
+ * Read-access of a symbol, like reading a variable.
1493
+ */
1494
+ DocumentHighlightKind.Read = 2;
1495
+ /**
1496
+ * Write-access of a symbol, like writing to a variable.
1497
+ */
1498
+ DocumentHighlightKind.Write = 3;
1499
+ })(DocumentHighlightKind || (exports.DocumentHighlightKind = DocumentHighlightKind = {}));
1500
+ /**
1501
+ * DocumentHighlight namespace to provide helper functions to work with
1502
+ * {@link DocumentHighlight} literals.
1503
+ */
1504
+ var DocumentHighlight;
1505
+ (function (DocumentHighlight) {
1506
+ /**
1507
+ * Create a DocumentHighlight object.
1508
+ * @param range The range the highlight applies to.
1509
+ * @param kind The highlight kind
1510
+ */
1511
+ function create(range, kind) {
1512
+ var result = { range: range };
1513
+ if (Is.number(kind)) {
1514
+ result.kind = kind;
1515
+ }
1516
+ return result;
1517
+ }
1518
+ DocumentHighlight.create = create;
1519
+ })(DocumentHighlight || (exports.DocumentHighlight = DocumentHighlight = {}));
1520
+ /**
1521
+ * A symbol kind.
1522
+ */
1523
+ var SymbolKind;
1524
+ (function (SymbolKind) {
1525
+ SymbolKind.File = 1;
1526
+ SymbolKind.Module = 2;
1527
+ SymbolKind.Namespace = 3;
1528
+ SymbolKind.Package = 4;
1529
+ SymbolKind.Class = 5;
1530
+ SymbolKind.Method = 6;
1531
+ SymbolKind.Property = 7;
1532
+ SymbolKind.Field = 8;
1533
+ SymbolKind.Constructor = 9;
1534
+ SymbolKind.Enum = 10;
1535
+ SymbolKind.Interface = 11;
1536
+ SymbolKind.Function = 12;
1537
+ SymbolKind.Variable = 13;
1538
+ SymbolKind.Constant = 14;
1539
+ SymbolKind.String = 15;
1540
+ SymbolKind.Number = 16;
1541
+ SymbolKind.Boolean = 17;
1542
+ SymbolKind.Array = 18;
1543
+ SymbolKind.Object = 19;
1544
+ SymbolKind.Key = 20;
1545
+ SymbolKind.Null = 21;
1546
+ SymbolKind.EnumMember = 22;
1547
+ SymbolKind.Struct = 23;
1548
+ SymbolKind.Event = 24;
1549
+ SymbolKind.Operator = 25;
1550
+ SymbolKind.TypeParameter = 26;
1551
+ })(SymbolKind || (exports.SymbolKind = SymbolKind = {}));
1552
+ /**
1553
+ * Symbol tags are extra annotations that tweak the rendering of a symbol.
1554
+ *
1555
+ * @since 3.16
1556
+ */
1557
+ var SymbolTag;
1558
+ (function (SymbolTag) {
1559
+ /**
1560
+ * Render a symbol as obsolete, usually using a strike-out.
1561
+ */
1562
+ SymbolTag.Deprecated = 1;
1563
+ })(SymbolTag || (exports.SymbolTag = SymbolTag = {}));
1564
+ var SymbolInformation;
1565
+ (function (SymbolInformation) {
1566
+ /**
1567
+ * Creates a new symbol information literal.
1568
+ *
1569
+ * @param name The name of the symbol.
1570
+ * @param kind The kind of the symbol.
1571
+ * @param range The range of the location of the symbol.
1572
+ * @param uri The resource of the location of symbol.
1573
+ * @param containerName The name of the symbol containing the symbol.
1574
+ */
1575
+ function create(name, kind, range, uri, containerName) {
1576
+ var result = {
1577
+ name: name,
1578
+ kind: kind,
1579
+ location: { uri: uri, range: range }
1580
+ };
1581
+ if (containerName) {
1582
+ result.containerName = containerName;
1583
+ }
1584
+ return result;
1585
+ }
1586
+ SymbolInformation.create = create;
1587
+ })(SymbolInformation || (exports.SymbolInformation = SymbolInformation = {}));
1588
+ var WorkspaceSymbol;
1589
+ (function (WorkspaceSymbol) {
1590
+ /**
1591
+ * Create a new workspace symbol.
1592
+ *
1593
+ * @param name The name of the symbol.
1594
+ * @param kind The kind of the symbol.
1595
+ * @param uri The resource of the location of the symbol.
1596
+ * @param range An options range of the location.
1597
+ * @returns A WorkspaceSymbol.
1598
+ */
1599
+ function create(name, kind, uri, range) {
1600
+ return range !== undefined
1601
+ ? { name: name, kind: kind, location: { uri: uri, range: range } }
1602
+ : { name: name, kind: kind, location: { uri: uri } };
1603
+ }
1604
+ WorkspaceSymbol.create = create;
1605
+ })(WorkspaceSymbol || (exports.WorkspaceSymbol = WorkspaceSymbol = {}));
1606
+ var DocumentSymbol;
1607
+ (function (DocumentSymbol) {
1608
+ /**
1609
+ * Creates a new symbol information literal.
1610
+ *
1611
+ * @param name The name of the symbol.
1612
+ * @param detail The detail of the symbol.
1613
+ * @param kind The kind of the symbol.
1614
+ * @param range The range of the symbol.
1615
+ * @param selectionRange The selectionRange of the symbol.
1616
+ * @param children Children of the symbol.
1617
+ */
1618
+ function create(name, detail, kind, range, selectionRange, children) {
1619
+ var result = {
1620
+ name: name,
1621
+ detail: detail,
1622
+ kind: kind,
1623
+ range: range,
1624
+ selectionRange: selectionRange
1625
+ };
1626
+ if (children !== undefined) {
1627
+ result.children = children;
1628
+ }
1629
+ return result;
1630
+ }
1631
+ DocumentSymbol.create = create;
1632
+ /**
1633
+ * Checks whether the given literal conforms to the {@link DocumentSymbol} interface.
1634
+ */
1635
+ function is(value) {
1636
+ var candidate = value;
1637
+ return candidate &&
1638
+ Is.string(candidate.name) && Is.number(candidate.kind) &&
1639
+ Range.is(candidate.range) && Range.is(candidate.selectionRange) &&
1640
+ (candidate.detail === undefined || Is.string(candidate.detail)) &&
1641
+ (candidate.deprecated === undefined || Is.boolean(candidate.deprecated)) &&
1642
+ (candidate.children === undefined || Array.isArray(candidate.children)) &&
1643
+ (candidate.tags === undefined || Array.isArray(candidate.tags));
1644
+ }
1645
+ DocumentSymbol.is = is;
1646
+ })(DocumentSymbol || (exports.DocumentSymbol = DocumentSymbol = {}));
1647
+ /**
1648
+ * A set of predefined code action kinds
1649
+ */
1650
+ var CodeActionKind;
1651
+ (function (CodeActionKind) {
1652
+ /**
1653
+ * Empty kind.
1654
+ */
1655
+ CodeActionKind.Empty = '';
1656
+ /**
1657
+ * Base kind for quickfix actions: 'quickfix'
1658
+ */
1659
+ CodeActionKind.QuickFix = 'quickfix';
1660
+ /**
1661
+ * Base kind for refactoring actions: 'refactor'
1662
+ */
1663
+ CodeActionKind.Refactor = 'refactor';
1664
+ /**
1665
+ * Base kind for refactoring extraction actions: 'refactor.extract'
1666
+ *
1667
+ * Example extract actions:
1668
+ *
1669
+ * - Extract method
1670
+ * - Extract function
1671
+ * - Extract variable
1672
+ * - Extract interface from class
1673
+ * - ...
1674
+ */
1675
+ CodeActionKind.RefactorExtract = 'refactor.extract';
1676
+ /**
1677
+ * Base kind for refactoring inline actions: 'refactor.inline'
1678
+ *
1679
+ * Example inline actions:
1680
+ *
1681
+ * - Inline function
1682
+ * - Inline variable
1683
+ * - Inline constant
1684
+ * - ...
1685
+ */
1686
+ CodeActionKind.RefactorInline = 'refactor.inline';
1687
+ /**
1688
+ * Base kind for refactoring move actions: `refactor.move`
1689
+ *
1690
+ * Example move actions:
1691
+ *
1692
+ * - Move a function to a new file
1693
+ * - Move a property between classes
1694
+ * - Move method to base class
1695
+ * - ...
1696
+ *
1697
+ * @since 3.18.0
1698
+ */
1699
+ CodeActionKind.RefactorMove = 'refactor.move';
1700
+ /**
1701
+ * Base kind for refactoring rewrite actions: 'refactor.rewrite'
1702
+ *
1703
+ * Example rewrite actions:
1704
+ *
1705
+ * - Convert JavaScript function to class
1706
+ * - Add or remove parameter
1707
+ * - Encapsulate field
1708
+ * - Make method static
1709
+ * - Move method to base class
1710
+ * - ...
1711
+ */
1712
+ CodeActionKind.RefactorRewrite = 'refactor.rewrite';
1713
+ /**
1714
+ * Base kind for source actions: `source`
1715
+ *
1716
+ * Source code actions apply to the entire file.
1717
+ */
1718
+ CodeActionKind.Source = 'source';
1719
+ /**
1720
+ * Base kind for an organize imports source action: `source.organizeImports`
1721
+ */
1722
+ CodeActionKind.SourceOrganizeImports = 'source.organizeImports';
1723
+ /**
1724
+ * Base kind for auto-fix source actions: `source.fixAll`.
1725
+ *
1726
+ * Fix all actions automatically fix errors that have a clear fix that do not require user input.
1727
+ * They should not suppress errors or perform unsafe fixes such as generating new types or classes.
1728
+ *
1729
+ * @since 3.15.0
1730
+ */
1731
+ CodeActionKind.SourceFixAll = 'source.fixAll';
1732
+ /**
1733
+ * Base kind for all code actions applying to the entire notebook's scope. CodeActionKinds using
1734
+ * this should always begin with `notebook.`
1735
+ *
1736
+ * @since 3.18.0
1737
+ */
1738
+ CodeActionKind.Notebook = 'notebook';
1739
+ })(CodeActionKind || (exports.CodeActionKind = CodeActionKind = {}));
1740
+ /**
1741
+ * The reason why code actions were requested.
1742
+ *
1743
+ * @since 3.17.0
1744
+ */
1745
+ var CodeActionTriggerKind;
1746
+ (function (CodeActionTriggerKind) {
1747
+ /**
1748
+ * Code actions were explicitly requested by the user or by an extension.
1749
+ */
1750
+ CodeActionTriggerKind.Invoked = 1;
1751
+ /**
1752
+ * Code actions were requested automatically.
1753
+ *
1754
+ * This typically happens when current selection in a file changes, but can
1755
+ * also be triggered when file content changes.
1756
+ */
1757
+ CodeActionTriggerKind.Automatic = 2;
1758
+ })(CodeActionTriggerKind || (exports.CodeActionTriggerKind = CodeActionTriggerKind = {}));
1759
+ /**
1760
+ * The CodeActionContext namespace provides helper functions to work with
1761
+ * {@link CodeActionContext} literals.
1762
+ */
1763
+ var CodeActionContext;
1764
+ (function (CodeActionContext) {
1765
+ /**
1766
+ * Creates a new CodeActionContext literal.
1767
+ */
1768
+ function create(diagnostics, only, triggerKind) {
1769
+ var result = { diagnostics: diagnostics };
1770
+ if (only !== undefined && only !== null) {
1771
+ result.only = only;
1772
+ }
1773
+ if (triggerKind !== undefined && triggerKind !== null) {
1774
+ result.triggerKind = triggerKind;
1775
+ }
1776
+ return result;
1777
+ }
1778
+ CodeActionContext.create = create;
1779
+ /**
1780
+ * Checks whether the given literal conforms to the {@link CodeActionContext} interface.
1781
+ */
1782
+ function is(value) {
1783
+ var candidate = value;
1784
+ return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic.is)
1785
+ && (candidate.only === undefined || Is.typedArray(candidate.only, Is.string))
1786
+ && (candidate.triggerKind === undefined || candidate.triggerKind === CodeActionTriggerKind.Invoked || candidate.triggerKind === CodeActionTriggerKind.Automatic);
1787
+ }
1788
+ CodeActionContext.is = is;
1789
+ })(CodeActionContext || (exports.CodeActionContext = CodeActionContext = {}));
1790
+ /**
1791
+ * Code action tags are extra annotations that tweak the behavior of a code action.
1792
+ *
1793
+ * @since 3.18.0
1794
+ */
1795
+ var CodeActionTag;
1796
+ (function (CodeActionTag) {
1797
+ /**
1798
+ * Marks the code action as LLM-generated.
1799
+ */
1800
+ CodeActionTag.LLMGenerated = 1;
1801
+ /**
1802
+ * Checks whether the given literal conforms to the {@link CodeActionTag} interface.
1803
+ */
1804
+ function is(value) {
1805
+ return Is.defined(value) && value === CodeActionTag.LLMGenerated;
1806
+ }
1807
+ CodeActionTag.is = is;
1808
+ })(CodeActionTag || (exports.CodeActionTag = CodeActionTag = {}));
1809
+ var CodeAction;
1810
+ (function (CodeAction) {
1811
+ function create(title, kindOrCommandOrEdit, kind) {
1812
+ var result = { title: title };
1813
+ var checkKind = true;
1814
+ if (typeof kindOrCommandOrEdit === 'string') {
1815
+ checkKind = false;
1816
+ result.kind = kindOrCommandOrEdit;
1817
+ }
1818
+ else if (Command.is(kindOrCommandOrEdit)) {
1819
+ result.command = kindOrCommandOrEdit;
1820
+ }
1821
+ else {
1822
+ result.edit = kindOrCommandOrEdit;
1823
+ }
1824
+ if (checkKind && kind !== undefined) {
1825
+ result.kind = kind;
1826
+ }
1827
+ return result;
1828
+ }
1829
+ CodeAction.create = create;
1830
+ function is(value) {
1831
+ var candidate = value;
1832
+ return candidate && Is.string(candidate.title) &&
1833
+ (candidate.diagnostics === undefined || Is.typedArray(candidate.diagnostics, Diagnostic.is)) &&
1834
+ (candidate.kind === undefined || Is.string(candidate.kind)) &&
1835
+ (candidate.edit !== undefined || candidate.command !== undefined) &&
1836
+ (candidate.command === undefined || Command.is(candidate.command)) &&
1837
+ (candidate.isPreferred === undefined || Is.boolean(candidate.isPreferred)) &&
1838
+ (candidate.edit === undefined || WorkspaceEdit.is(candidate.edit)) &&
1839
+ (candidate.tags === undefined || Is.typedArray(candidate.tags, CodeActionTag.is));
1840
+ }
1841
+ CodeAction.is = is;
1842
+ })(CodeAction || (exports.CodeAction = CodeAction = {}));
1843
+ /**
1844
+ * The CodeLens namespace provides helper functions to work with
1845
+ * {@link CodeLens} literals.
1846
+ */
1847
+ var CodeLens;
1848
+ (function (CodeLens) {
1849
+ /**
1850
+ * Creates a new CodeLens literal.
1851
+ */
1852
+ function create(range, data) {
1853
+ var result = { range: range };
1854
+ if (Is.defined(data)) {
1855
+ result.data = data;
1856
+ }
1857
+ return result;
1858
+ }
1859
+ CodeLens.create = create;
1860
+ /**
1861
+ * Checks whether the given literal conforms to the {@link CodeLens} interface.
1862
+ */
1863
+ function is(value) {
1864
+ var candidate = value;
1865
+ return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
1866
+ }
1867
+ CodeLens.is = is;
1868
+ })(CodeLens || (exports.CodeLens = CodeLens = {}));
1869
+ /**
1870
+ * The FormattingOptions namespace provides helper functions to work with
1871
+ * {@link FormattingOptions} literals.
1872
+ */
1873
+ var FormattingOptions;
1874
+ (function (FormattingOptions) {
1875
+ /**
1876
+ * Creates a new FormattingOptions literal.
1877
+ */
1878
+ function create(tabSize, insertSpaces) {
1879
+ return { tabSize: tabSize, insertSpaces: insertSpaces };
1880
+ }
1881
+ FormattingOptions.create = create;
1882
+ /**
1883
+ * Checks whether the given literal conforms to the {@link FormattingOptions} interface.
1884
+ */
1885
+ function is(value) {
1886
+ var candidate = value;
1887
+ return Is.defined(candidate) && Is.uinteger(candidate.tabSize) && Is.boolean(candidate.insertSpaces);
1888
+ }
1889
+ FormattingOptions.is = is;
1890
+ })(FormattingOptions || (exports.FormattingOptions = FormattingOptions = {}));
1891
+ /**
1892
+ * The DocumentLink namespace provides helper functions to work with
1893
+ * {@link DocumentLink} literals.
1894
+ */
1895
+ var DocumentLink;
1896
+ (function (DocumentLink) {
1897
+ /**
1898
+ * Creates a new DocumentLink literal.
1899
+ */
1900
+ function create(range, target, data) {
1901
+ return { range: range, target: target, data: data };
1902
+ }
1903
+ DocumentLink.create = create;
1904
+ /**
1905
+ * Checks whether the given literal conforms to the {@link DocumentLink} interface.
1906
+ */
1907
+ function is(value) {
1908
+ var candidate = value;
1909
+ return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
1910
+ }
1911
+ DocumentLink.is = is;
1912
+ })(DocumentLink || (exports.DocumentLink = DocumentLink = {}));
1913
+ /**
1914
+ * The SelectionRange namespace provides helper function to work with
1915
+ * SelectionRange literals.
1916
+ */
1917
+ var SelectionRange;
1918
+ (function (SelectionRange) {
1919
+ /**
1920
+ * Creates a new SelectionRange
1921
+ * @param range the range.
1922
+ * @param parent an optional parent.
1923
+ */
1924
+ function create(range, parent) {
1925
+ return { range: range, parent: parent };
1926
+ }
1927
+ SelectionRange.create = create;
1928
+ function is(value) {
1929
+ var candidate = value;
1930
+ return Is.objectLiteral(candidate) && Range.is(candidate.range) && (candidate.parent === undefined || SelectionRange.is(candidate.parent));
1931
+ }
1932
+ SelectionRange.is = is;
1933
+ })(SelectionRange || (exports.SelectionRange = SelectionRange = {}));
1934
+ /**
1935
+ * A set of predefined token types. This set is not fixed
1936
+ * an clients can specify additional token types via the
1937
+ * corresponding client capabilities.
1938
+ *
1939
+ * @since 3.16.0
1940
+ */
1941
+ var SemanticTokenTypes;
1942
+ (function (SemanticTokenTypes) {
1943
+ SemanticTokenTypes["namespace"] = "namespace";
1944
+ /**
1945
+ * Represents a generic type. Acts as a fallback for types which can't be mapped to
1946
+ * a specific type like class or enum.
1947
+ */
1948
+ SemanticTokenTypes["type"] = "type";
1949
+ SemanticTokenTypes["class"] = "class";
1950
+ SemanticTokenTypes["enum"] = "enum";
1951
+ SemanticTokenTypes["interface"] = "interface";
1952
+ SemanticTokenTypes["struct"] = "struct";
1953
+ SemanticTokenTypes["typeParameter"] = "typeParameter";
1954
+ SemanticTokenTypes["parameter"] = "parameter";
1955
+ SemanticTokenTypes["variable"] = "variable";
1956
+ SemanticTokenTypes["property"] = "property";
1957
+ SemanticTokenTypes["enumMember"] = "enumMember";
1958
+ SemanticTokenTypes["event"] = "event";
1959
+ SemanticTokenTypes["function"] = "function";
1960
+ SemanticTokenTypes["method"] = "method";
1961
+ SemanticTokenTypes["macro"] = "macro";
1962
+ SemanticTokenTypes["keyword"] = "keyword";
1963
+ SemanticTokenTypes["modifier"] = "modifier";
1964
+ SemanticTokenTypes["comment"] = "comment";
1965
+ SemanticTokenTypes["string"] = "string";
1966
+ SemanticTokenTypes["number"] = "number";
1967
+ SemanticTokenTypes["regexp"] = "regexp";
1968
+ SemanticTokenTypes["operator"] = "operator";
1969
+ /**
1970
+ * @since 3.17.0
1971
+ */
1972
+ SemanticTokenTypes["decorator"] = "decorator";
1973
+ /**
1974
+ * @since 3.18.0
1975
+ */
1976
+ SemanticTokenTypes["label"] = "label";
1977
+ })(SemanticTokenTypes || (exports.SemanticTokenTypes = SemanticTokenTypes = {}));
1978
+ /**
1979
+ * A set of predefined token modifiers. This set is not fixed
1980
+ * an clients can specify additional token types via the
1981
+ * corresponding client capabilities.
1982
+ *
1983
+ * @since 3.16.0
1984
+ */
1985
+ var SemanticTokenModifiers;
1986
+ (function (SemanticTokenModifiers) {
1987
+ SemanticTokenModifiers["declaration"] = "declaration";
1988
+ SemanticTokenModifiers["definition"] = "definition";
1989
+ SemanticTokenModifiers["readonly"] = "readonly";
1990
+ SemanticTokenModifiers["static"] = "static";
1991
+ SemanticTokenModifiers["deprecated"] = "deprecated";
1992
+ SemanticTokenModifiers["abstract"] = "abstract";
1993
+ SemanticTokenModifiers["async"] = "async";
1994
+ SemanticTokenModifiers["modification"] = "modification";
1995
+ SemanticTokenModifiers["documentation"] = "documentation";
1996
+ SemanticTokenModifiers["defaultLibrary"] = "defaultLibrary";
1997
+ })(SemanticTokenModifiers || (exports.SemanticTokenModifiers = SemanticTokenModifiers = {}));
1998
+ /**
1999
+ * @since 3.16.0
2000
+ */
2001
+ var SemanticTokens;
2002
+ (function (SemanticTokens) {
2003
+ function is(value) {
2004
+ var candidate = value;
2005
+ return Is.objectLiteral(candidate) && (candidate.resultId === undefined || typeof candidate.resultId === 'string') &&
2006
+ Array.isArray(candidate.data) && (candidate.data.length === 0 || typeof candidate.data[0] === 'number');
2007
+ }
2008
+ SemanticTokens.is = is;
2009
+ })(SemanticTokens || (exports.SemanticTokens = SemanticTokens = {}));
2010
+ /**
2011
+ * The InlineValueText namespace provides functions to deal with InlineValueTexts.
2012
+ *
2013
+ * @since 3.17.0
2014
+ */
2015
+ var InlineValueText;
2016
+ (function (InlineValueText) {
2017
+ /**
2018
+ * Creates a new InlineValueText literal.
2019
+ */
2020
+ function create(range, text) {
2021
+ return { range: range, text: text };
2022
+ }
2023
+ InlineValueText.create = create;
2024
+ function is(value) {
2025
+ var candidate = value;
2026
+ return candidate !== undefined && candidate !== null && Range.is(candidate.range) && Is.string(candidate.text);
2027
+ }
2028
+ InlineValueText.is = is;
2029
+ })(InlineValueText || (exports.InlineValueText = InlineValueText = {}));
2030
+ /**
2031
+ * The InlineValueVariableLookup namespace provides functions to
2032
+ * deal with InlineValueVariableLookups.
2033
+ *
2034
+ * @since 3.17.0
2035
+ */
2036
+ var InlineValueVariableLookup;
2037
+ (function (InlineValueVariableLookup) {
2038
+ /**
2039
+ * Creates a new InlineValueText literal.
2040
+ */
2041
+ function create(range, variableName, caseSensitiveLookup) {
2042
+ return { range: range, variableName: variableName, caseSensitiveLookup: caseSensitiveLookup };
2043
+ }
2044
+ InlineValueVariableLookup.create = create;
2045
+ function is(value) {
2046
+ var candidate = value;
2047
+ return candidate !== undefined && candidate !== null && Range.is(candidate.range) && Is.boolean(candidate.caseSensitiveLookup)
2048
+ && (Is.string(candidate.variableName) || candidate.variableName === undefined);
2049
+ }
2050
+ InlineValueVariableLookup.is = is;
2051
+ })(InlineValueVariableLookup || (exports.InlineValueVariableLookup = InlineValueVariableLookup = {}));
2052
+ /**
2053
+ * The InlineValueEvaluatableExpression namespace provides functions to deal with InlineValueEvaluatableExpression.
2054
+ *
2055
+ * @since 3.17.0
2056
+ */
2057
+ var InlineValueEvaluatableExpression;
2058
+ (function (InlineValueEvaluatableExpression) {
2059
+ /**
2060
+ * Creates a new InlineValueEvaluatableExpression literal.
2061
+ */
2062
+ function create(range, expression) {
2063
+ return { range: range, expression: expression };
2064
+ }
2065
+ InlineValueEvaluatableExpression.create = create;
2066
+ function is(value) {
2067
+ var candidate = value;
2068
+ return candidate !== undefined && candidate !== null && Range.is(candidate.range)
2069
+ && (Is.string(candidate.expression) || candidate.expression === undefined);
2070
+ }
2071
+ InlineValueEvaluatableExpression.is = is;
2072
+ })(InlineValueEvaluatableExpression || (exports.InlineValueEvaluatableExpression = InlineValueEvaluatableExpression = {}));
2073
+ /**
2074
+ * The InlineValueContext namespace provides helper functions to work with
2075
+ * {@link InlineValueContext} literals.
2076
+ *
2077
+ * @since 3.17.0
2078
+ */
2079
+ var InlineValueContext;
2080
+ (function (InlineValueContext) {
2081
+ /**
2082
+ * Creates a new InlineValueContext literal.
2083
+ */
2084
+ function create(frameId, stoppedLocation) {
2085
+ return { frameId: frameId, stoppedLocation: stoppedLocation };
2086
+ }
2087
+ InlineValueContext.create = create;
2088
+ /**
2089
+ * Checks whether the given literal conforms to the {@link InlineValueContext} interface.
2090
+ */
2091
+ function is(value) {
2092
+ var candidate = value;
2093
+ return Is.defined(candidate) && Range.is(value.stoppedLocation);
2094
+ }
2095
+ InlineValueContext.is = is;
2096
+ })(InlineValueContext || (exports.InlineValueContext = InlineValueContext = {}));
2097
+ /**
2098
+ * Inlay hint kinds.
2099
+ *
2100
+ * @since 3.17.0
2101
+ */
2102
+ var InlayHintKind;
2103
+ (function (InlayHintKind) {
2104
+ /**
2105
+ * An inlay hint that for a type annotation.
2106
+ */
2107
+ InlayHintKind.Type = 1;
2108
+ /**
2109
+ * An inlay hint that is for a parameter.
2110
+ */
2111
+ InlayHintKind.Parameter = 2;
2112
+ function is(value) {
2113
+ return value === 1 || value === 2;
2114
+ }
2115
+ InlayHintKind.is = is;
2116
+ })(InlayHintKind || (exports.InlayHintKind = InlayHintKind = {}));
2117
+ var InlayHintLabelPart;
2118
+ (function (InlayHintLabelPart) {
2119
+ function create(value) {
2120
+ return { value: value };
2121
+ }
2122
+ InlayHintLabelPart.create = create;
2123
+ function is(value) {
2124
+ var candidate = value;
2125
+ return Is.objectLiteral(candidate)
2126
+ && (candidate.tooltip === undefined || Is.string(candidate.tooltip) || MarkupContent.is(candidate.tooltip))
2127
+ && (candidate.location === undefined || Location.is(candidate.location))
2128
+ && (candidate.command === undefined || Command.is(candidate.command));
2129
+ }
2130
+ InlayHintLabelPart.is = is;
2131
+ })(InlayHintLabelPart || (exports.InlayHintLabelPart = InlayHintLabelPart = {}));
2132
+ var InlayHint;
2133
+ (function (InlayHint) {
2134
+ function create(position, label, kind) {
2135
+ var result = { position: position, label: label };
2136
+ if (kind !== undefined) {
2137
+ result.kind = kind;
2138
+ }
2139
+ return result;
2140
+ }
2141
+ InlayHint.create = create;
2142
+ function is(value) {
2143
+ var candidate = value;
2144
+ return Is.objectLiteral(candidate) && Position.is(candidate.position)
2145
+ && (Is.string(candidate.label) || Is.typedArray(candidate.label, InlayHintLabelPart.is))
2146
+ && (candidate.kind === undefined || InlayHintKind.is(candidate.kind))
2147
+ && (candidate.textEdits === undefined) || Is.typedArray(candidate.textEdits, TextEdit.is)
2148
+ && (candidate.tooltip === undefined || Is.string(candidate.tooltip) || MarkupContent.is(candidate.tooltip))
2149
+ && (candidate.paddingLeft === undefined || Is.boolean(candidate.paddingLeft))
2150
+ && (candidate.paddingRight === undefined || Is.boolean(candidate.paddingRight));
2151
+ }
2152
+ InlayHint.is = is;
2153
+ })(InlayHint || (exports.InlayHint = InlayHint = {}));
2154
+ var StringValue;
2155
+ (function (StringValue) {
2156
+ function createSnippet(value) {
2157
+ return { kind: 'snippet', value: value };
2158
+ }
2159
+ StringValue.createSnippet = createSnippet;
2160
+ function isSnippet(value) {
2161
+ var candidate = value;
2162
+ return Is.objectLiteral(candidate)
2163
+ && candidate.kind === 'snippet'
2164
+ && Is.string(candidate.value);
2165
+ }
2166
+ StringValue.isSnippet = isSnippet;
2167
+ })(StringValue || (exports.StringValue = StringValue = {}));
2168
+ var InlineCompletionItem;
2169
+ (function (InlineCompletionItem) {
2170
+ function create(insertText, filterText, range, command) {
2171
+ return { insertText: insertText, filterText: filterText, range: range, command: command };
2172
+ }
2173
+ InlineCompletionItem.create = create;
2174
+ })(InlineCompletionItem || (exports.InlineCompletionItem = InlineCompletionItem = {}));
2175
+ var InlineCompletionList;
2176
+ (function (InlineCompletionList) {
2177
+ function create(items) {
2178
+ return { items: items };
2179
+ }
2180
+ InlineCompletionList.create = create;
2181
+ })(InlineCompletionList || (exports.InlineCompletionList = InlineCompletionList = {}));
2182
+ /**
2183
+ * Describes how an {@link InlineCompletionItemProvider inline completion provider} was triggered.
2184
+ *
2185
+ * @since 3.18.0
2186
+ */
2187
+ var InlineCompletionTriggerKind;
2188
+ (function (InlineCompletionTriggerKind) {
2189
+ /**
2190
+ * Completion was triggered explicitly by a user gesture.
2191
+ */
2192
+ InlineCompletionTriggerKind.Invoked = 1;
2193
+ /**
2194
+ * Completion was triggered automatically while editing.
2195
+ */
2196
+ InlineCompletionTriggerKind.Automatic = 2;
2197
+ })(InlineCompletionTriggerKind || (exports.InlineCompletionTriggerKind = InlineCompletionTriggerKind = {}));
2198
+ var SelectedCompletionInfo;
2199
+ (function (SelectedCompletionInfo) {
2200
+ function create(range, text) {
2201
+ return { range: range, text: text };
2202
+ }
2203
+ SelectedCompletionInfo.create = create;
2204
+ })(SelectedCompletionInfo || (exports.SelectedCompletionInfo = SelectedCompletionInfo = {}));
2205
+ var InlineCompletionContext;
2206
+ (function (InlineCompletionContext) {
2207
+ function create(triggerKind, selectedCompletionInfo) {
2208
+ return { triggerKind: triggerKind, selectedCompletionInfo: selectedCompletionInfo };
2209
+ }
2210
+ InlineCompletionContext.create = create;
2211
+ })(InlineCompletionContext || (exports.InlineCompletionContext = InlineCompletionContext = {}));
2212
+ var WorkspaceFolder;
2213
+ (function (WorkspaceFolder) {
2214
+ function is(value) {
2215
+ var candidate = value;
2216
+ return Is.objectLiteral(candidate) && URI.is(candidate.uri) && Is.string(candidate.name);
2217
+ }
2218
+ WorkspaceFolder.is = is;
2219
+ })(WorkspaceFolder || (exports.WorkspaceFolder = WorkspaceFolder = {}));
2220
+ exports.EOL = ['\n', '\r\n', '\r'];
2221
+ /**
2222
+ * @deprecated Use the text document from the new vscode-languageserver-textdocument package.
2223
+ */
2224
+ var TextDocument;
2225
+ (function (TextDocument) {
2226
+ /**
2227
+ * Creates a new ITextDocument literal from the given uri and content.
2228
+ * @param uri The document's uri.
2229
+ * @param languageId The document's language Id.
2230
+ * @param version The document's version.
2231
+ * @param content The document's content.
2232
+ */
2233
+ function create(uri, languageId, version, content) {
2234
+ return new FullTextDocument(uri, languageId, version, content);
2235
+ }
2236
+ TextDocument.create = create;
2237
+ /**
2238
+ * Checks whether the given literal conforms to the {@link ITextDocument} interface.
2239
+ */
2240
+ function is(value) {
2241
+ var candidate = value;
2242
+ return Is.defined(candidate) && Is.string(candidate.uri) && (Is.undefined(candidate.languageId) || Is.string(candidate.languageId)) && Is.uinteger(candidate.lineCount)
2243
+ && Is.func(candidate.getText) && Is.func(candidate.positionAt) && Is.func(candidate.offsetAt) ? true : false;
2244
+ }
2245
+ TextDocument.is = is;
2246
+ function applyEdits(document, edits) {
2247
+ var text = document.getText();
2248
+ var sortedEdits = mergeSort(edits, function (a, b) {
2249
+ var diff = a.range.start.line - b.range.start.line;
2250
+ if (diff === 0) {
2251
+ return a.range.start.character - b.range.start.character;
2252
+ }
2253
+ return diff;
2254
+ });
2255
+ var lastModifiedOffset = text.length;
2256
+ for (var i = sortedEdits.length - 1; i >= 0; i--) {
2257
+ var e = sortedEdits[i];
2258
+ var startOffset = document.offsetAt(e.range.start);
2259
+ var endOffset = document.offsetAt(e.range.end);
2260
+ if (endOffset <= lastModifiedOffset) {
2261
+ text = text.substring(0, startOffset) + e.newText + text.substring(endOffset, text.length);
2262
+ }
2263
+ else {
2264
+ throw new Error('Overlapping edit');
2265
+ }
2266
+ lastModifiedOffset = startOffset;
2267
+ }
2268
+ return text;
2269
+ }
2270
+ TextDocument.applyEdits = applyEdits;
2271
+ function mergeSort(data, compare) {
2272
+ if (data.length <= 1) {
2273
+ // sorted
2274
+ return data;
2275
+ }
2276
+ var p = (data.length / 2) | 0;
2277
+ var left = data.slice(0, p);
2278
+ var right = data.slice(p);
2279
+ mergeSort(left, compare);
2280
+ mergeSort(right, compare);
2281
+ var leftIdx = 0;
2282
+ var rightIdx = 0;
2283
+ var i = 0;
2284
+ while (leftIdx < left.length && rightIdx < right.length) {
2285
+ var ret = compare(left[leftIdx], right[rightIdx]);
2286
+ if (ret <= 0) {
2287
+ // smaller_equal -> take left to preserve order
2288
+ data[i++] = left[leftIdx++];
2289
+ }
2290
+ else {
2291
+ // greater -> take right
2292
+ data[i++] = right[rightIdx++];
2293
+ }
2294
+ }
2295
+ while (leftIdx < left.length) {
2296
+ data[i++] = left[leftIdx++];
2297
+ }
2298
+ while (rightIdx < right.length) {
2299
+ data[i++] = right[rightIdx++];
2300
+ }
2301
+ return data;
2302
+ }
2303
+ })(TextDocument || (exports.TextDocument = TextDocument = {}));
2304
+ /**
2305
+ * @deprecated Use the text document from the new vscode-languageserver-textdocument package.
2306
+ */
2307
+ var FullTextDocument = /** @class */ (function () {
2308
+ function FullTextDocument(uri, languageId, version, content) {
2309
+ this._uri = uri;
2310
+ this._languageId = languageId;
2311
+ this._version = version;
2312
+ this._content = content;
2313
+ this._lineOffsets = undefined;
2314
+ }
2315
+ Object.defineProperty(FullTextDocument.prototype, "uri", {
2316
+ get: function () {
2317
+ return this._uri;
2318
+ },
2319
+ enumerable: false,
2320
+ configurable: true
2321
+ });
2322
+ Object.defineProperty(FullTextDocument.prototype, "languageId", {
2323
+ get: function () {
2324
+ return this._languageId;
2325
+ },
2326
+ enumerable: false,
2327
+ configurable: true
2328
+ });
2329
+ Object.defineProperty(FullTextDocument.prototype, "version", {
2330
+ get: function () {
2331
+ return this._version;
2332
+ },
2333
+ enumerable: false,
2334
+ configurable: true
2335
+ });
2336
+ FullTextDocument.prototype.getText = function (range) {
2337
+ if (range) {
2338
+ var start = this.offsetAt(range.start);
2339
+ var end = this.offsetAt(range.end);
2340
+ return this._content.substring(start, end);
2341
+ }
2342
+ return this._content;
2343
+ };
2344
+ FullTextDocument.prototype.update = function (event, version) {
2345
+ this._content = event.text;
2346
+ this._version = version;
2347
+ this._lineOffsets = undefined;
2348
+ };
2349
+ FullTextDocument.prototype.getLineOffsets = function () {
2350
+ if (this._lineOffsets === undefined) {
2351
+ var lineOffsets = [];
2352
+ var text = this._content;
2353
+ var isLineStart = true;
2354
+ for (var i = 0; i < text.length; i++) {
2355
+ if (isLineStart) {
2356
+ lineOffsets.push(i);
2357
+ isLineStart = false;
2358
+ }
2359
+ var ch = text.charAt(i);
2360
+ isLineStart = (ch === '\r' || ch === '\n');
2361
+ if (ch === '\r' && i + 1 < text.length && text.charAt(i + 1) === '\n') {
2362
+ i++;
2363
+ }
2364
+ }
2365
+ if (isLineStart && text.length > 0) {
2366
+ lineOffsets.push(text.length);
2367
+ }
2368
+ this._lineOffsets = lineOffsets;
2369
+ }
2370
+ return this._lineOffsets;
2371
+ };
2372
+ FullTextDocument.prototype.positionAt = function (offset) {
2373
+ offset = Math.max(Math.min(offset, this._content.length), 0);
2374
+ var lineOffsets = this.getLineOffsets();
2375
+ var low = 0, high = lineOffsets.length;
2376
+ if (high === 0) {
2377
+ return Position.create(0, offset);
2378
+ }
2379
+ while (low < high) {
2380
+ var mid = Math.floor((low + high) / 2);
2381
+ if (lineOffsets[mid] > offset) {
2382
+ high = mid;
2383
+ }
2384
+ else {
2385
+ low = mid + 1;
2386
+ }
2387
+ }
2388
+ // low is the least x for which the line offset is larger than the current offset
2389
+ // or array.length if no line offset is larger than the current offset
2390
+ var line = low - 1;
2391
+ return Position.create(line, offset - lineOffsets[line]);
2392
+ };
2393
+ FullTextDocument.prototype.offsetAt = function (position) {
2394
+ var lineOffsets = this.getLineOffsets();
2395
+ if (position.line >= lineOffsets.length) {
2396
+ return this._content.length;
2397
+ }
2398
+ else if (position.line < 0) {
2399
+ return 0;
2400
+ }
2401
+ var lineOffset = lineOffsets[position.line];
2402
+ var nextLineOffset = (position.line + 1 < lineOffsets.length) ? lineOffsets[position.line + 1] : this._content.length;
2403
+ return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);
2404
+ };
2405
+ Object.defineProperty(FullTextDocument.prototype, "lineCount", {
2406
+ get: function () {
2407
+ return this.getLineOffsets().length;
2408
+ },
2409
+ enumerable: false,
2410
+ configurable: true
2411
+ });
2412
+ return FullTextDocument;
2413
+ }());
2414
+ var Is;
2415
+ (function (Is) {
2416
+ var toString = Object.prototype.toString;
2417
+ function defined(value) {
2418
+ return typeof value !== 'undefined';
2419
+ }
2420
+ Is.defined = defined;
2421
+ function undefined(value) {
2422
+ return typeof value === 'undefined';
2423
+ }
2424
+ Is.undefined = undefined;
2425
+ function boolean(value) {
2426
+ return value === true || value === false;
2427
+ }
2428
+ Is.boolean = boolean;
2429
+ function string(value) {
2430
+ return toString.call(value) === '[object String]';
2431
+ }
2432
+ Is.string = string;
2433
+ function number(value) {
2434
+ return toString.call(value) === '[object Number]';
2435
+ }
2436
+ Is.number = number;
2437
+ function numberRange(value, min, max) {
2438
+ return toString.call(value) === '[object Number]' && min <= value && value <= max;
2439
+ }
2440
+ Is.numberRange = numberRange;
2441
+ function integer(value) {
2442
+ return toString.call(value) === '[object Number]' && -2147483648 <= value && value <= 2147483647;
2443
+ }
2444
+ Is.integer = integer;
2445
+ function uinteger(value) {
2446
+ return toString.call(value) === '[object Number]' && 0 <= value && value <= 2147483647;
2447
+ }
2448
+ Is.uinteger = uinteger;
2449
+ function func(value) {
2450
+ return toString.call(value) === '[object Function]';
2451
+ }
2452
+ Is.func = func;
2453
+ function objectLiteral(value) {
2454
+ // Strictly speaking class instances pass this check as well. Since the LSP
2455
+ // doesn't use classes we ignore this for now. If we do we need to add something
2456
+ // like this: `Object.getPrototypeOf(Object.getPrototypeOf(x)) === null`
2457
+ return value !== null && typeof value === 'object';
2458
+ }
2459
+ Is.objectLiteral = objectLiteral;
2460
+ function typedArray(value, check) {
2461
+ return Array.isArray(value) && value.every(check);
2462
+ }
2463
+ Is.typedArray = typedArray;
2464
+ })(Is || (Is = {}));
2465
+ });