massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-json / node_modules / vscode-languageserver-types / lib / esm / main.js
1 /* --------------------------------------------------------------------------------------------
2  * Copyright (c) Microsoft Corporation. All rights reserved.
3  * Licensed under the MIT License. See License.txt in the project root for license information.
4  * ------------------------------------------------------------------------------------------ */
5 'use strict';
6 export var integer;
7 (function (integer) {
8     integer.MIN_VALUE = -2147483648;
9     integer.MAX_VALUE = 2147483647;
10 })(integer || (integer = {}));
11 export var uinteger;
12 (function (uinteger) {
13     uinteger.MIN_VALUE = 0;
14     uinteger.MAX_VALUE = 2147483647;
15 })(uinteger || (uinteger = {}));
16 /**
17  * The Position namespace provides helper functions to work with
18  * [Position](#Position) literals.
19  */
20 export var Position;
21 (function (Position) {
22     /**
23      * Creates a new Position literal from the given line and character.
24      * @param line The position's line.
25      * @param character The position's character.
26      */
27     function create(line, character) {
28         if (line === Number.MAX_VALUE) {
29             line = uinteger.MAX_VALUE;
30         }
31         if (character === Number.MAX_VALUE) {
32             character = uinteger.MAX_VALUE;
33         }
34         return { line: line, character: character };
35     }
36     Position.create = create;
37     /**
38      * Checks whether the given literal conforms to the [Position](#Position) interface.
39      */
40     function is(value) {
41         var candidate = value;
42         return Is.objectLiteral(candidate) && Is.uinteger(candidate.line) && Is.uinteger(candidate.character);
43     }
44     Position.is = is;
45 })(Position || (Position = {}));
46 /**
47  * The Range namespace provides helper functions to work with
48  * [Range](#Range) literals.
49  */
50 export var Range;
51 (function (Range) {
52     function create(one, two, three, four) {
53         if (Is.uinteger(one) && Is.uinteger(two) && Is.uinteger(three) && Is.uinteger(four)) {
54             return { start: Position.create(one, two), end: Position.create(three, four) };
55         }
56         else if (Position.is(one) && Position.is(two)) {
57             return { start: one, end: two };
58         }
59         else {
60             throw new Error("Range#create called with invalid arguments[" + one + ", " + two + ", " + three + ", " + four + "]");
61         }
62     }
63     Range.create = create;
64     /**
65      * Checks whether the given literal conforms to the [Range](#Range) interface.
66      */
67     function is(value) {
68         var candidate = value;
69         return Is.objectLiteral(candidate) && Position.is(candidate.start) && Position.is(candidate.end);
70     }
71     Range.is = is;
72 })(Range || (Range = {}));
73 /**
74  * The Location namespace provides helper functions to work with
75  * [Location](#Location) literals.
76  */
77 export var Location;
78 (function (Location) {
79     /**
80      * Creates a Location literal.
81      * @param uri The location's uri.
82      * @param range The location's range.
83      */
84     function create(uri, range) {
85         return { uri: uri, range: range };
86     }
87     Location.create = create;
88     /**
89      * Checks whether the given literal conforms to the [Location](#Location) interface.
90      */
91     function is(value) {
92         var candidate = value;
93         return Is.defined(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
94     }
95     Location.is = is;
96 })(Location || (Location = {}));
97 /**
98  * The LocationLink namespace provides helper functions to work with
99  * [LocationLink](#LocationLink) literals.
100  */
101 export var LocationLink;
102 (function (LocationLink) {
103     /**
104      * Creates a LocationLink literal.
105      * @param targetUri The definition's uri.
106      * @param targetRange The full range of the definition.
107      * @param targetSelectionRange The span of the symbol definition at the target.
108      * @param originSelectionRange The span of the symbol being defined in the originating source file.
109      */
110     function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) {
111         return { targetUri: targetUri, targetRange: targetRange, targetSelectionRange: targetSelectionRange, originSelectionRange: originSelectionRange };
112     }
113     LocationLink.create = create;
114     /**
115      * Checks whether the given literal conforms to the [LocationLink](#LocationLink) interface.
116      */
117     function is(value) {
118         var candidate = value;
119         return Is.defined(candidate) && Range.is(candidate.targetRange) && Is.string(candidate.targetUri)
120             && (Range.is(candidate.targetSelectionRange) || Is.undefined(candidate.targetSelectionRange))
121             && (Range.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));
122     }
123     LocationLink.is = is;
124 })(LocationLink || (LocationLink = {}));
125 /**
126  * The Color namespace provides helper functions to work with
127  * [Color](#Color) literals.
128  */
129 export var Color;
130 (function (Color) {
131     /**
132      * Creates a new Color literal.
133      */
134     function create(red, green, blue, alpha) {
135         return {
136             red: red,
137             green: green,
138             blue: blue,
139             alpha: alpha,
140         };
141     }
142     Color.create = create;
143     /**
144      * Checks whether the given literal conforms to the [Color](#Color) interface.
145      */
146     function is(value) {
147         var candidate = value;
148         return Is.numberRange(candidate.red, 0, 1)
149             && Is.numberRange(candidate.green, 0, 1)
150             && Is.numberRange(candidate.blue, 0, 1)
151             && Is.numberRange(candidate.alpha, 0, 1);
152     }
153     Color.is = is;
154 })(Color || (Color = {}));
155 /**
156  * The ColorInformation namespace provides helper functions to work with
157  * [ColorInformation](#ColorInformation) literals.
158  */
159 export var ColorInformation;
160 (function (ColorInformation) {
161     /**
162      * Creates a new ColorInformation literal.
163      */
164     function create(range, color) {
165         return {
166             range: range,
167             color: color,
168         };
169     }
170     ColorInformation.create = create;
171     /**
172      * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
173      */
174     function is(value) {
175         var candidate = value;
176         return Range.is(candidate.range) && Color.is(candidate.color);
177     }
178     ColorInformation.is = is;
179 })(ColorInformation || (ColorInformation = {}));
180 /**
181  * The Color namespace provides helper functions to work with
182  * [ColorPresentation](#ColorPresentation) literals.
183  */
184 export var ColorPresentation;
185 (function (ColorPresentation) {
186     /**
187      * Creates a new ColorInformation literal.
188      */
189     function create(label, textEdit, additionalTextEdits) {
190         return {
191             label: label,
192             textEdit: textEdit,
193             additionalTextEdits: additionalTextEdits,
194         };
195     }
196     ColorPresentation.create = create;
197     /**
198      * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
199      */
200     function is(value) {
201         var candidate = value;
202         return Is.string(candidate.label)
203             && (Is.undefined(candidate.textEdit) || TextEdit.is(candidate))
204             && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit.is));
205     }
206     ColorPresentation.is = is;
207 })(ColorPresentation || (ColorPresentation = {}));
208 /**
209  * Enum of known range kinds
210  */
211 export var FoldingRangeKind;
212 (function (FoldingRangeKind) {
213     /**
214      * Folding range for a comment
215      */
216     FoldingRangeKind["Comment"] = "comment";
217     /**
218      * Folding range for a imports or includes
219      */
220     FoldingRangeKind["Imports"] = "imports";
221     /**
222      * Folding range for a region (e.g. `#region`)
223      */
224     FoldingRangeKind["Region"] = "region";
225 })(FoldingRangeKind || (FoldingRangeKind = {}));
226 /**
227  * The folding range namespace provides helper functions to work with
228  * [FoldingRange](#FoldingRange) literals.
229  */
230 export var FoldingRange;
231 (function (FoldingRange) {
232     /**
233      * Creates a new FoldingRange literal.
234      */
235     function create(startLine, endLine, startCharacter, endCharacter, kind) {
236         var result = {
237             startLine: startLine,
238             endLine: endLine
239         };
240         if (Is.defined(startCharacter)) {
241             result.startCharacter = startCharacter;
242         }
243         if (Is.defined(endCharacter)) {
244             result.endCharacter = endCharacter;
245         }
246         if (Is.defined(kind)) {
247             result.kind = kind;
248         }
249         return result;
250     }
251     FoldingRange.create = create;
252     /**
253      * Checks whether the given literal conforms to the [FoldingRange](#FoldingRange) interface.
254      */
255     function is(value) {
256         var candidate = value;
257         return Is.uinteger(candidate.startLine) && Is.uinteger(candidate.startLine)
258             && (Is.undefined(candidate.startCharacter) || Is.uinteger(candidate.startCharacter))
259             && (Is.undefined(candidate.endCharacter) || Is.uinteger(candidate.endCharacter))
260             && (Is.undefined(candidate.kind) || Is.string(candidate.kind));
261     }
262     FoldingRange.is = is;
263 })(FoldingRange || (FoldingRange = {}));
264 /**
265  * The DiagnosticRelatedInformation namespace provides helper functions to work with
266  * [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) literals.
267  */
268 export var DiagnosticRelatedInformation;
269 (function (DiagnosticRelatedInformation) {
270     /**
271      * Creates a new DiagnosticRelatedInformation literal.
272      */
273     function create(location, message) {
274         return {
275             location: location,
276             message: message
277         };
278     }
279     DiagnosticRelatedInformation.create = create;
280     /**
281      * Checks whether the given literal conforms to the [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) interface.
282      */
283     function is(value) {
284         var candidate = value;
285         return Is.defined(candidate) && Location.is(candidate.location) && Is.string(candidate.message);
286     }
287     DiagnosticRelatedInformation.is = is;
288 })(DiagnosticRelatedInformation || (DiagnosticRelatedInformation = {}));
289 /**
290  * The diagnostic's severity.
291  */
292 export var DiagnosticSeverity;
293 (function (DiagnosticSeverity) {
294     /**
295      * Reports an error.
296      */
297     DiagnosticSeverity.Error = 1;
298     /**
299      * Reports a warning.
300      */
301     DiagnosticSeverity.Warning = 2;
302     /**
303      * Reports an information.
304      */
305     DiagnosticSeverity.Information = 3;
306     /**
307      * Reports a hint.
308      */
309     DiagnosticSeverity.Hint = 4;
310 })(DiagnosticSeverity || (DiagnosticSeverity = {}));
311 /**
312  * The diagnostic tags.
313  *
314  * @since 3.15.0
315  */
316 export var DiagnosticTag;
317 (function (DiagnosticTag) {
318     /**
319      * Unused or unnecessary code.
320      *
321      * Clients are allowed to render diagnostics with this tag faded out instead of having
322      * an error squiggle.
323      */
324     DiagnosticTag.Unnecessary = 1;
325     /**
326      * Deprecated or obsolete code.
327      *
328      * Clients are allowed to rendered diagnostics with this tag strike through.
329      */
330     DiagnosticTag.Deprecated = 2;
331 })(DiagnosticTag || (DiagnosticTag = {}));
332 /**
333  * The CodeDescription namespace provides functions to deal with descriptions for diagnostic codes.
334  *
335  * @since 3.16.0
336  */
337 export var CodeDescription;
338 (function (CodeDescription) {
339     function is(value) {
340         var candidate = value;
341         return candidate !== undefined && candidate !== null && Is.string(candidate.href);
342     }
343     CodeDescription.is = is;
344 })(CodeDescription || (CodeDescription = {}));
345 /**
346  * The Diagnostic namespace provides helper functions to work with
347  * [Diagnostic](#Diagnostic) literals.
348  */
349 export var Diagnostic;
350 (function (Diagnostic) {
351     /**
352      * Creates a new Diagnostic literal.
353      */
354     function create(range, message, severity, code, source, relatedInformation) {
355         var result = { range: range, message: message };
356         if (Is.defined(severity)) {
357             result.severity = severity;
358         }
359         if (Is.defined(code)) {
360             result.code = code;
361         }
362         if (Is.defined(source)) {
363             result.source = source;
364         }
365         if (Is.defined(relatedInformation)) {
366             result.relatedInformation = relatedInformation;
367         }
368         return result;
369     }
370     Diagnostic.create = create;
371     /**
372      * Checks whether the given literal conforms to the [Diagnostic](#Diagnostic) interface.
373      */
374     function is(value) {
375         var _a;
376         var candidate = value;
377         return Is.defined(candidate)
378             && Range.is(candidate.range)
379             && Is.string(candidate.message)
380             && (Is.number(candidate.severity) || Is.undefined(candidate.severity))
381             && (Is.integer(candidate.code) || Is.string(candidate.code) || Is.undefined(candidate.code))
382             && (Is.undefined(candidate.codeDescription) || (Is.string((_a = candidate.codeDescription) === null || _a === void 0 ? void 0 : _a.href)))
383             && (Is.string(candidate.source) || Is.undefined(candidate.source))
384             && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is));
385     }
386     Diagnostic.is = is;
387 })(Diagnostic || (Diagnostic = {}));
388 /**
389  * The Command namespace provides helper functions to work with
390  * [Command](#Command) literals.
391  */
392 export var Command;
393 (function (Command) {
394     /**
395      * Creates a new Command literal.
396      */
397     function create(title, command) {
398         var args = [];
399         for (var _i = 2; _i < arguments.length; _i++) {
400             args[_i - 2] = arguments[_i];
401         }
402         var result = { title: title, command: command };
403         if (Is.defined(args) && args.length > 0) {
404             result.arguments = args;
405         }
406         return result;
407     }
408     Command.create = create;
409     /**
410      * Checks whether the given literal conforms to the [Command](#Command) interface.
411      */
412     function is(value) {
413         var candidate = value;
414         return Is.defined(candidate) && Is.string(candidate.title) && Is.string(candidate.command);
415     }
416     Command.is = is;
417 })(Command || (Command = {}));
418 /**
419  * The TextEdit namespace provides helper function to create replace,
420  * insert and delete edits more easily.
421  */
422 export var TextEdit;
423 (function (TextEdit) {
424     /**
425      * Creates a replace text edit.
426      * @param range The range of text to be replaced.
427      * @param newText The new text.
428      */
429     function replace(range, newText) {
430         return { range: range, newText: newText };
431     }
432     TextEdit.replace = replace;
433     /**
434      * Creates a insert text edit.
435      * @param position The position to insert the text at.
436      * @param newText The text to be inserted.
437      */
438     function insert(position, newText) {
439         return { range: { start: position, end: position }, newText: newText };
440     }
441     TextEdit.insert = insert;
442     /**
443      * Creates a delete text edit.
444      * @param range The range of text to be deleted.
445      */
446     function del(range) {
447         return { range: range, newText: '' };
448     }
449     TextEdit.del = del;
450     function is(value) {
451         var candidate = value;
452         return Is.objectLiteral(candidate)
453             && Is.string(candidate.newText)
454             && Range.is(candidate.range);
455     }
456     TextEdit.is = is;
457 })(TextEdit || (TextEdit = {}));
458 export var ChangeAnnotation;
459 (function (ChangeAnnotation) {
460     function create(label, needsConfirmation, description) {
461         var result = { label: label };
462         if (needsConfirmation !== undefined) {
463             result.needsConfirmation = needsConfirmation;
464         }
465         if (description !== undefined) {
466             result.description = description;
467         }
468         return result;
469     }
470     ChangeAnnotation.create = create;
471     function is(value) {
472         var candidate = value;
473         return candidate !== undefined && Is.objectLiteral(candidate) && Is.string(candidate.label) &&
474             (Is.boolean(candidate.needsConfirmation) || candidate.needsConfirmation === undefined) &&
475             (Is.string(candidate.description) || candidate.description === undefined);
476     }
477     ChangeAnnotation.is = is;
478 })(ChangeAnnotation || (ChangeAnnotation = {}));
479 export var ChangeAnnotationIdentifier;
480 (function (ChangeAnnotationIdentifier) {
481     function is(value) {
482         var candidate = value;
483         return typeof candidate === 'string';
484     }
485     ChangeAnnotationIdentifier.is = is;
486 })(ChangeAnnotationIdentifier || (ChangeAnnotationIdentifier = {}));
487 export var AnnotatedTextEdit;
488 (function (AnnotatedTextEdit) {
489     /**
490      * Creates an annotated replace text edit.
491      *
492      * @param range The range of text to be replaced.
493      * @param newText The new text.
494      * @param annotation The annotation.
495      */
496     function replace(range, newText, annotation) {
497         return { range: range, newText: newText, annotationId: annotation };
498     }
499     AnnotatedTextEdit.replace = replace;
500     /**
501      * Creates an annotated insert text edit.
502      *
503      * @param position The position to insert the text at.
504      * @param newText The text to be inserted.
505      * @param annotation The annotation.
506      */
507     function insert(position, newText, annotation) {
508         return { range: { start: position, end: position }, newText: newText, annotationId: annotation };
509     }
510     AnnotatedTextEdit.insert = insert;
511     /**
512      * Creates an annotated delete text edit.
513      *
514      * @param range The range of text to be deleted.
515      * @param annotation The annotation.
516      */
517     function del(range, annotation) {
518         return { range: range, newText: '', annotationId: annotation };
519     }
520     AnnotatedTextEdit.del = del;
521     function is(value) {
522         var candidate = value;
523         return TextEdit.is(candidate) && (ChangeAnnotation.is(candidate.annotationId) || ChangeAnnotationIdentifier.is(candidate.annotationId));
524     }
525     AnnotatedTextEdit.is = is;
526 })(AnnotatedTextEdit || (AnnotatedTextEdit = {}));
527 /**
528  * The TextDocumentEdit namespace provides helper function to create
529  * an edit that manipulates a text document.
530  */
531 export var TextDocumentEdit;
532 (function (TextDocumentEdit) {
533     /**
534      * Creates a new `TextDocumentEdit`
535      */
536     function create(textDocument, edits) {
537         return { textDocument: textDocument, edits: edits };
538     }
539     TextDocumentEdit.create = create;
540     function is(value) {
541         var candidate = value;
542         return Is.defined(candidate)
543             && OptionalVersionedTextDocumentIdentifier.is(candidate.textDocument)
544             && Array.isArray(candidate.edits);
545     }
546     TextDocumentEdit.is = is;
547 })(TextDocumentEdit || (TextDocumentEdit = {}));
548 export var CreateFile;
549 (function (CreateFile) {
550     function create(uri, options, annotation) {
551         var result = {
552             kind: 'create',
553             uri: uri
554         };
555         if (options !== undefined && (options.overwrite !== undefined || options.ignoreIfExists !== undefined)) {
556             result.options = options;
557         }
558         if (annotation !== undefined) {
559             result.annotationId = annotation;
560         }
561         return result;
562     }
563     CreateFile.create = create;
564     function is(value) {
565         var candidate = value;
566         return candidate && candidate.kind === 'create' && Is.string(candidate.uri) && (candidate.options === undefined ||
567             ((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));
568     }
569     CreateFile.is = is;
570 })(CreateFile || (CreateFile = {}));
571 export var RenameFile;
572 (function (RenameFile) {
573     function create(oldUri, newUri, options, annotation) {
574         var result = {
575             kind: 'rename',
576             oldUri: oldUri,
577             newUri: newUri
578         };
579         if (options !== undefined && (options.overwrite !== undefined || options.ignoreIfExists !== undefined)) {
580             result.options = options;
581         }
582         if (annotation !== undefined) {
583             result.annotationId = annotation;
584         }
585         return result;
586     }
587     RenameFile.create = create;
588     function is(value) {
589         var candidate = value;
590         return candidate && candidate.kind === 'rename' && Is.string(candidate.oldUri) && Is.string(candidate.newUri) && (candidate.options === undefined ||
591             ((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));
592     }
593     RenameFile.is = is;
594 })(RenameFile || (RenameFile = {}));
595 export var DeleteFile;
596 (function (DeleteFile) {
597     function create(uri, options, annotation) {
598         var result = {
599             kind: 'delete',
600             uri: uri
601         };
602         if (options !== undefined && (options.recursive !== undefined || options.ignoreIfNotExists !== undefined)) {
603             result.options = options;
604         }
605         if (annotation !== undefined) {
606             result.annotationId = annotation;
607         }
608         return result;
609     }
610     DeleteFile.create = create;
611     function is(value) {
612         var candidate = value;
613         return candidate && candidate.kind === 'delete' && Is.string(candidate.uri) && (candidate.options === undefined ||
614             ((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));
615     }
616     DeleteFile.is = is;
617 })(DeleteFile || (DeleteFile = {}));
618 export var WorkspaceEdit;
619 (function (WorkspaceEdit) {
620     function is(value) {
621         var candidate = value;
622         return candidate &&
623             (candidate.changes !== undefined || candidate.documentChanges !== undefined) &&
624             (candidate.documentChanges === undefined || candidate.documentChanges.every(function (change) {
625                 if (Is.string(change.kind)) {
626                     return CreateFile.is(change) || RenameFile.is(change) || DeleteFile.is(change);
627                 }
628                 else {
629                     return TextDocumentEdit.is(change);
630                 }
631             }));
632     }
633     WorkspaceEdit.is = is;
634 })(WorkspaceEdit || (WorkspaceEdit = {}));
635 var TextEditChangeImpl = /** @class */ (function () {
636     function TextEditChangeImpl(edits, changeAnnotations) {
637         this.edits = edits;
638         this.changeAnnotations = changeAnnotations;
639     }
640     TextEditChangeImpl.prototype.insert = function (position, newText, annotation) {
641         var edit;
642         var id;
643         if (annotation === undefined) {
644             edit = TextEdit.insert(position, newText);
645         }
646         else if (ChangeAnnotationIdentifier.is(annotation)) {
647             id = annotation;
648             edit = AnnotatedTextEdit.insert(position, newText, annotation);
649         }
650         else {
651             this.assertChangeAnnotations(this.changeAnnotations);
652             id = this.changeAnnotations.manage(annotation);
653             edit = AnnotatedTextEdit.insert(position, newText, id);
654         }
655         this.edits.push(edit);
656         if (id !== undefined) {
657             return id;
658         }
659     };
660     TextEditChangeImpl.prototype.replace = function (range, newText, annotation) {
661         var edit;
662         var id;
663         if (annotation === undefined) {
664             edit = TextEdit.replace(range, newText);
665         }
666         else if (ChangeAnnotationIdentifier.is(annotation)) {
667             id = annotation;
668             edit = AnnotatedTextEdit.replace(range, newText, annotation);
669         }
670         else {
671             this.assertChangeAnnotations(this.changeAnnotations);
672             id = this.changeAnnotations.manage(annotation);
673             edit = AnnotatedTextEdit.replace(range, newText, id);
674         }
675         this.edits.push(edit);
676         if (id !== undefined) {
677             return id;
678         }
679     };
680     TextEditChangeImpl.prototype.delete = function (range, annotation) {
681         var edit;
682         var id;
683         if (annotation === undefined) {
684             edit = TextEdit.del(range);
685         }
686         else if (ChangeAnnotationIdentifier.is(annotation)) {
687             id = annotation;
688             edit = AnnotatedTextEdit.del(range, annotation);
689         }
690         else {
691             this.assertChangeAnnotations(this.changeAnnotations);
692             id = this.changeAnnotations.manage(annotation);
693             edit = AnnotatedTextEdit.del(range, id);
694         }
695         this.edits.push(edit);
696         if (id !== undefined) {
697             return id;
698         }
699     };
700     TextEditChangeImpl.prototype.add = function (edit) {
701         this.edits.push(edit);
702     };
703     TextEditChangeImpl.prototype.all = function () {
704         return this.edits;
705     };
706     TextEditChangeImpl.prototype.clear = function () {
707         this.edits.splice(0, this.edits.length);
708     };
709     TextEditChangeImpl.prototype.assertChangeAnnotations = function (value) {
710         if (value === undefined) {
711             throw new Error("Text edit change is not configured to manage change annotations.");
712         }
713     };
714     return TextEditChangeImpl;
715 }());
716 /**
717  * A helper class
718  */
719 var ChangeAnnotations = /** @class */ (function () {
720     function ChangeAnnotations(annotations) {
721         this._annotations = annotations === undefined ? Object.create(null) : annotations;
722         this._counter = 0;
723         this._size = 0;
724     }
725     ChangeAnnotations.prototype.all = function () {
726         return this._annotations;
727     };
728     Object.defineProperty(ChangeAnnotations.prototype, "size", {
729         get: function () {
730             return this._size;
731         },
732         enumerable: false,
733         configurable: true
734     });
735     ChangeAnnotations.prototype.manage = function (idOrAnnotation, annotation) {
736         var id;
737         if (ChangeAnnotationIdentifier.is(idOrAnnotation)) {
738             id = idOrAnnotation;
739         }
740         else {
741             id = this.nextId();
742             annotation = idOrAnnotation;
743         }
744         if (this._annotations[id] !== undefined) {
745             throw new Error("Id " + id + " is already in use.");
746         }
747         if (annotation === undefined) {
748             throw new Error("No annotation provided for id " + id);
749         }
750         this._annotations[id] = annotation;
751         this._size++;
752         return id;
753     };
754     ChangeAnnotations.prototype.nextId = function () {
755         this._counter++;
756         return this._counter.toString();
757     };
758     return ChangeAnnotations;
759 }());
760 /**
761  * A workspace change helps constructing changes to a workspace.
762  */
763 var WorkspaceChange = /** @class */ (function () {
764     function WorkspaceChange(workspaceEdit) {
765         var _this = this;
766         this._textEditChanges = Object.create(null);
767         if (workspaceEdit !== undefined) {
768             this._workspaceEdit = workspaceEdit;
769             if (workspaceEdit.documentChanges) {
770                 this._changeAnnotations = new ChangeAnnotations(workspaceEdit.changeAnnotations);
771                 workspaceEdit.changeAnnotations = this._changeAnnotations.all();
772                 workspaceEdit.documentChanges.forEach(function (change) {
773                     if (TextDocumentEdit.is(change)) {
774                         var textEditChange = new TextEditChangeImpl(change.edits, _this._changeAnnotations);
775                         _this._textEditChanges[change.textDocument.uri] = textEditChange;
776                     }
777                 });
778             }
779             else if (workspaceEdit.changes) {
780                 Object.keys(workspaceEdit.changes).forEach(function (key) {
781                     var textEditChange = new TextEditChangeImpl(workspaceEdit.changes[key]);
782                     _this._textEditChanges[key] = textEditChange;
783                 });
784             }
785         }
786         else {
787             this._workspaceEdit = {};
788         }
789     }
790     Object.defineProperty(WorkspaceChange.prototype, "edit", {
791         /**
792          * Returns the underlying [WorkspaceEdit](#WorkspaceEdit) literal
793          * use to be returned from a workspace edit operation like rename.
794          */
795         get: function () {
796             this.initDocumentChanges();
797             if (this._changeAnnotations !== undefined) {
798                 if (this._changeAnnotations.size === 0) {
799                     this._workspaceEdit.changeAnnotations = undefined;
800                 }
801                 else {
802                     this._workspaceEdit.changeAnnotations = this._changeAnnotations.all();
803                 }
804             }
805             return this._workspaceEdit;
806         },
807         enumerable: false,
808         configurable: true
809     });
810     WorkspaceChange.prototype.getTextEditChange = function (key) {
811         if (OptionalVersionedTextDocumentIdentifier.is(key)) {
812             this.initDocumentChanges();
813             if (this._workspaceEdit.documentChanges === undefined) {
814                 throw new Error('Workspace edit is not configured for document changes.');
815             }
816             var textDocument = { uri: key.uri, version: key.version };
817             var result = this._textEditChanges[textDocument.uri];
818             if (!result) {
819                 var edits = [];
820                 var textDocumentEdit = {
821                     textDocument: textDocument,
822                     edits: edits
823                 };
824                 this._workspaceEdit.documentChanges.push(textDocumentEdit);
825                 result = new TextEditChangeImpl(edits, this._changeAnnotations);
826                 this._textEditChanges[textDocument.uri] = result;
827             }
828             return result;
829         }
830         else {
831             this.initChanges();
832             if (this._workspaceEdit.changes === undefined) {
833                 throw new Error('Workspace edit is not configured for normal text edit changes.');
834             }
835             var result = this._textEditChanges[key];
836             if (!result) {
837                 var edits = [];
838                 this._workspaceEdit.changes[key] = edits;
839                 result = new TextEditChangeImpl(edits);
840                 this._textEditChanges[key] = result;
841             }
842             return result;
843         }
844     };
845     WorkspaceChange.prototype.initDocumentChanges = function () {
846         if (this._workspaceEdit.documentChanges === undefined && this._workspaceEdit.changes === undefined) {
847             this._changeAnnotations = new ChangeAnnotations();
848             this._workspaceEdit.documentChanges = [];
849             this._workspaceEdit.changeAnnotations = this._changeAnnotations.all();
850         }
851     };
852     WorkspaceChange.prototype.initChanges = function () {
853         if (this._workspaceEdit.documentChanges === undefined && this._workspaceEdit.changes === undefined) {
854             this._workspaceEdit.changes = Object.create(null);
855         }
856     };
857     WorkspaceChange.prototype.createFile = function (uri, optionsOrAnnotation, options) {
858         this.initDocumentChanges();
859         if (this._workspaceEdit.documentChanges === undefined) {
860             throw new Error('Workspace edit is not configured for document changes.');
861         }
862         var annotation;
863         if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) {
864             annotation = optionsOrAnnotation;
865         }
866         else {
867             options = optionsOrAnnotation;
868         }
869         var operation;
870         var id;
871         if (annotation === undefined) {
872             operation = CreateFile.create(uri, options);
873         }
874         else {
875             id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation);
876             operation = CreateFile.create(uri, options, id);
877         }
878         this._workspaceEdit.documentChanges.push(operation);
879         if (id !== undefined) {
880             return id;
881         }
882     };
883     WorkspaceChange.prototype.renameFile = function (oldUri, newUri, optionsOrAnnotation, options) {
884         this.initDocumentChanges();
885         if (this._workspaceEdit.documentChanges === undefined) {
886             throw new Error('Workspace edit is not configured for document changes.');
887         }
888         var annotation;
889         if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) {
890             annotation = optionsOrAnnotation;
891         }
892         else {
893             options = optionsOrAnnotation;
894         }
895         var operation;
896         var id;
897         if (annotation === undefined) {
898             operation = RenameFile.create(oldUri, newUri, options);
899         }
900         else {
901             id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation);
902             operation = RenameFile.create(oldUri, newUri, options, id);
903         }
904         this._workspaceEdit.documentChanges.push(operation);
905         if (id !== undefined) {
906             return id;
907         }
908     };
909     WorkspaceChange.prototype.deleteFile = function (uri, optionsOrAnnotation, options) {
910         this.initDocumentChanges();
911         if (this._workspaceEdit.documentChanges === undefined) {
912             throw new Error('Workspace edit is not configured for document changes.');
913         }
914         var annotation;
915         if (ChangeAnnotation.is(optionsOrAnnotation) || ChangeAnnotationIdentifier.is(optionsOrAnnotation)) {
916             annotation = optionsOrAnnotation;
917         }
918         else {
919             options = optionsOrAnnotation;
920         }
921         var operation;
922         var id;
923         if (annotation === undefined) {
924             operation = DeleteFile.create(uri, options);
925         }
926         else {
927             id = ChangeAnnotationIdentifier.is(annotation) ? annotation : this._changeAnnotations.manage(annotation);
928             operation = DeleteFile.create(uri, options, id);
929         }
930         this._workspaceEdit.documentChanges.push(operation);
931         if (id !== undefined) {
932             return id;
933         }
934     };
935     return WorkspaceChange;
936 }());
937 export { WorkspaceChange };
938 /**
939  * The TextDocumentIdentifier namespace provides helper functions to work with
940  * [TextDocumentIdentifier](#TextDocumentIdentifier) literals.
941  */
942 export var TextDocumentIdentifier;
943 (function (TextDocumentIdentifier) {
944     /**
945      * Creates a new TextDocumentIdentifier literal.
946      * @param uri The document's uri.
947      */
948     function create(uri) {
949         return { uri: uri };
950     }
951     TextDocumentIdentifier.create = create;
952     /**
953      * Checks whether the given literal conforms to the [TextDocumentIdentifier](#TextDocumentIdentifier) interface.
954      */
955     function is(value) {
956         var candidate = value;
957         return Is.defined(candidate) && Is.string(candidate.uri);
958     }
959     TextDocumentIdentifier.is = is;
960 })(TextDocumentIdentifier || (TextDocumentIdentifier = {}));
961 /**
962  * The VersionedTextDocumentIdentifier namespace provides helper functions to work with
963  * [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) literals.
964  */
965 export var VersionedTextDocumentIdentifier;
966 (function (VersionedTextDocumentIdentifier) {
967     /**
968      * Creates a new VersionedTextDocumentIdentifier literal.
969      * @param uri The document's uri.
970      * @param uri The document's text.
971      */
972     function create(uri, version) {
973         return { uri: uri, version: version };
974     }
975     VersionedTextDocumentIdentifier.create = create;
976     /**
977      * Checks whether the given literal conforms to the [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) interface.
978      */
979     function is(value) {
980         var candidate = value;
981         return Is.defined(candidate) && Is.string(candidate.uri) && Is.integer(candidate.version);
982     }
983     VersionedTextDocumentIdentifier.is = is;
984 })(VersionedTextDocumentIdentifier || (VersionedTextDocumentIdentifier = {}));
985 /**
986  * The OptionalVersionedTextDocumentIdentifier namespace provides helper functions to work with
987  * [OptionalVersionedTextDocumentIdentifier](#OptionalVersionedTextDocumentIdentifier) literals.
988  */
989 export var OptionalVersionedTextDocumentIdentifier;
990 (function (OptionalVersionedTextDocumentIdentifier) {
991     /**
992      * Creates a new OptionalVersionedTextDocumentIdentifier literal.
993      * @param uri The document's uri.
994      * @param uri The document's text.
995      */
996     function create(uri, version) {
997         return { uri: uri, version: version };
998     }
999     OptionalVersionedTextDocumentIdentifier.create = create;
1000     /**
1001      * Checks whether the given literal conforms to the [OptionalVersionedTextDocumentIdentifier](#OptionalVersionedTextDocumentIdentifier) interface.
1002      */
1003     function is(value) {
1004         var candidate = value;
1005         return Is.defined(candidate) && Is.string(candidate.uri) && (candidate.version === null || Is.integer(candidate.version));
1006     }
1007     OptionalVersionedTextDocumentIdentifier.is = is;
1008 })(OptionalVersionedTextDocumentIdentifier || (OptionalVersionedTextDocumentIdentifier = {}));
1009 /**
1010  * The TextDocumentItem namespace provides helper functions to work with
1011  * [TextDocumentItem](#TextDocumentItem) literals.
1012  */
1013 export var TextDocumentItem;
1014 (function (TextDocumentItem) {
1015     /**
1016      * Creates a new TextDocumentItem literal.
1017      * @param uri The document's uri.
1018      * @param languageId The document's language identifier.
1019      * @param version The document's version number.
1020      * @param text The document's text.
1021      */
1022     function create(uri, languageId, version, text) {
1023         return { uri: uri, languageId: languageId, version: version, text: text };
1024     }
1025     TextDocumentItem.create = create;
1026     /**
1027      * Checks whether the given literal conforms to the [TextDocumentItem](#TextDocumentItem) interface.
1028      */
1029     function is(value) {
1030         var candidate = value;
1031         return Is.defined(candidate) && Is.string(candidate.uri) && Is.string(candidate.languageId) && Is.integer(candidate.version) && Is.string(candidate.text);
1032     }
1033     TextDocumentItem.is = is;
1034 })(TextDocumentItem || (TextDocumentItem = {}));
1035 /**
1036  * Describes the content type that a client supports in various
1037  * result literals like `Hover`, `ParameterInfo` or `CompletionItem`.
1038  *
1039  * Please note that `MarkupKinds` must not start with a `$`. This kinds
1040  * are reserved for internal usage.
1041  */
1042 export var MarkupKind;
1043 (function (MarkupKind) {
1044     /**
1045      * Plain text is supported as a content format
1046      */
1047     MarkupKind.PlainText = 'plaintext';
1048     /**
1049      * Markdown is supported as a content format
1050      */
1051     MarkupKind.Markdown = 'markdown';
1052 })(MarkupKind || (MarkupKind = {}));
1053 (function (MarkupKind) {
1054     /**
1055      * Checks whether the given value is a value of the [MarkupKind](#MarkupKind) type.
1056      */
1057     function is(value) {
1058         var candidate = value;
1059         return candidate === MarkupKind.PlainText || candidate === MarkupKind.Markdown;
1060     }
1061     MarkupKind.is = is;
1062 })(MarkupKind || (MarkupKind = {}));
1063 export var MarkupContent;
1064 (function (MarkupContent) {
1065     /**
1066      * Checks whether the given value conforms to the [MarkupContent](#MarkupContent) interface.
1067      */
1068     function is(value) {
1069         var candidate = value;
1070         return Is.objectLiteral(value) && MarkupKind.is(candidate.kind) && Is.string(candidate.value);
1071     }
1072     MarkupContent.is = is;
1073 })(MarkupContent || (MarkupContent = {}));
1074 /**
1075  * The kind of a completion entry.
1076  */
1077 export var CompletionItemKind;
1078 (function (CompletionItemKind) {
1079     CompletionItemKind.Text = 1;
1080     CompletionItemKind.Method = 2;
1081     CompletionItemKind.Function = 3;
1082     CompletionItemKind.Constructor = 4;
1083     CompletionItemKind.Field = 5;
1084     CompletionItemKind.Variable = 6;
1085     CompletionItemKind.Class = 7;
1086     CompletionItemKind.Interface = 8;
1087     CompletionItemKind.Module = 9;
1088     CompletionItemKind.Property = 10;
1089     CompletionItemKind.Unit = 11;
1090     CompletionItemKind.Value = 12;
1091     CompletionItemKind.Enum = 13;
1092     CompletionItemKind.Keyword = 14;
1093     CompletionItemKind.Snippet = 15;
1094     CompletionItemKind.Color = 16;
1095     CompletionItemKind.File = 17;
1096     CompletionItemKind.Reference = 18;
1097     CompletionItemKind.Folder = 19;
1098     CompletionItemKind.EnumMember = 20;
1099     CompletionItemKind.Constant = 21;
1100     CompletionItemKind.Struct = 22;
1101     CompletionItemKind.Event = 23;
1102     CompletionItemKind.Operator = 24;
1103     CompletionItemKind.TypeParameter = 25;
1104 })(CompletionItemKind || (CompletionItemKind = {}));
1105 /**
1106  * Defines whether the insert text in a completion item should be interpreted as
1107  * plain text or a snippet.
1108  */
1109 export var InsertTextFormat;
1110 (function (InsertTextFormat) {
1111     /**
1112      * The primary text to be inserted is treated as a plain string.
1113      */
1114     InsertTextFormat.PlainText = 1;
1115     /**
1116      * The primary text to be inserted is treated as a snippet.
1117      *
1118      * A snippet can define tab stops and placeholders with `$1`, `$2`
1119      * and `${3:foo}`. `$0` defines the final tab stop, it defaults to
1120      * the end of the snippet. Placeholders with equal identifiers are linked,
1121      * that is typing in one will update others too.
1122      *
1123      * See also: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#snippet_syntax
1124      */
1125     InsertTextFormat.Snippet = 2;
1126 })(InsertTextFormat || (InsertTextFormat = {}));
1127 /**
1128  * Completion item tags are extra annotations that tweak the rendering of a completion
1129  * item.
1130  *
1131  * @since 3.15.0
1132  */
1133 export var CompletionItemTag;
1134 (function (CompletionItemTag) {
1135     /**
1136      * Render a completion as obsolete, usually using a strike-out.
1137      */
1138     CompletionItemTag.Deprecated = 1;
1139 })(CompletionItemTag || (CompletionItemTag = {}));
1140 /**
1141  * The InsertReplaceEdit namespace provides functions to deal with insert / replace edits.
1142  *
1143  * @since 3.16.0
1144  */
1145 export var InsertReplaceEdit;
1146 (function (InsertReplaceEdit) {
1147     /**
1148      * Creates a new insert / replace edit
1149      */
1150     function create(newText, insert, replace) {
1151         return { newText: newText, insert: insert, replace: replace };
1152     }
1153     InsertReplaceEdit.create = create;
1154     /**
1155      * Checks whether the given literal conforms to the [InsertReplaceEdit](#InsertReplaceEdit) interface.
1156      */
1157     function is(value) {
1158         var candidate = value;
1159         return candidate && Is.string(candidate.newText) && Range.is(candidate.insert) && Range.is(candidate.replace);
1160     }
1161     InsertReplaceEdit.is = is;
1162 })(InsertReplaceEdit || (InsertReplaceEdit = {}));
1163 /**
1164  * How whitespace and indentation is handled during completion
1165  * item insertion.
1166  *
1167  * @since 3.16.0
1168  */
1169 export var InsertTextMode;
1170 (function (InsertTextMode) {
1171     /**
1172      * The insertion or replace strings is taken as it is. If the
1173      * value is multi line the lines below the cursor will be
1174      * inserted using the indentation defined in the string value.
1175      * The client will not apply any kind of adjustments to the
1176      * string.
1177      */
1178     InsertTextMode.asIs = 1;
1179     /**
1180      * The editor adjusts leading whitespace of new lines so that
1181      * they match the indentation up to the cursor of the line for
1182      * which the item is accepted.
1183      *
1184      * Consider a line like this: <2tabs><cursor><3tabs>foo. Accepting a
1185      * multi line completion item is indented using 2 tabs and all
1186      * following lines inserted will be indented using 2 tabs as well.
1187      */
1188     InsertTextMode.adjustIndentation = 2;
1189 })(InsertTextMode || (InsertTextMode = {}));
1190 /**
1191  * The CompletionItem namespace provides functions to deal with
1192  * completion items.
1193  */
1194 export var CompletionItem;
1195 (function (CompletionItem) {
1196     /**
1197      * Create a completion item and seed it with a label.
1198      * @param label The completion item's label
1199      */
1200     function create(label) {
1201         return { label: label };
1202     }
1203     CompletionItem.create = create;
1204 })(CompletionItem || (CompletionItem = {}));
1205 /**
1206  * The CompletionList namespace provides functions to deal with
1207  * completion lists.
1208  */
1209 export var CompletionList;
1210 (function (CompletionList) {
1211     /**
1212      * Creates a new completion list.
1213      *
1214      * @param items The completion items.
1215      * @param isIncomplete The list is not complete.
1216      */
1217     function create(items, isIncomplete) {
1218         return { items: items ? items : [], isIncomplete: !!isIncomplete };
1219     }
1220     CompletionList.create = create;
1221 })(CompletionList || (CompletionList = {}));
1222 export var MarkedString;
1223 (function (MarkedString) {
1224     /**
1225      * Creates a marked string from plain text.
1226      *
1227      * @param plainText The plain text.
1228      */
1229     function fromPlainText(plainText) {
1230         return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&'); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
1231     }
1232     MarkedString.fromPlainText = fromPlainText;
1233     /**
1234      * Checks whether the given value conforms to the [MarkedString](#MarkedString) type.
1235      */
1236     function is(value) {
1237         var candidate = value;
1238         return Is.string(candidate) || (Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value));
1239     }
1240     MarkedString.is = is;
1241 })(MarkedString || (MarkedString = {}));
1242 export var Hover;
1243 (function (Hover) {
1244     /**
1245      * Checks whether the given value conforms to the [Hover](#Hover) interface.
1246      */
1247     function is(value) {
1248         var candidate = value;
1249         return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) ||
1250             MarkedString.is(candidate.contents) ||
1251             Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === undefined || Range.is(value.range));
1252     }
1253     Hover.is = is;
1254 })(Hover || (Hover = {}));
1255 /**
1256  * The ParameterInformation namespace provides helper functions to work with
1257  * [ParameterInformation](#ParameterInformation) literals.
1258  */
1259 export var ParameterInformation;
1260 (function (ParameterInformation) {
1261     /**
1262      * Creates a new parameter information literal.
1263      *
1264      * @param label A label string.
1265      * @param documentation A doc string.
1266      */
1267     function create(label, documentation) {
1268         return documentation ? { label: label, documentation: documentation } : { label: label };
1269     }
1270     ParameterInformation.create = create;
1271 })(ParameterInformation || (ParameterInformation = {}));
1272 /**
1273  * The SignatureInformation namespace provides helper functions to work with
1274  * [SignatureInformation](#SignatureInformation) literals.
1275  */
1276 export var SignatureInformation;
1277 (function (SignatureInformation) {
1278     function create(label, documentation) {
1279         var parameters = [];
1280         for (var _i = 2; _i < arguments.length; _i++) {
1281             parameters[_i - 2] = arguments[_i];
1282         }
1283         var result = { label: label };
1284         if (Is.defined(documentation)) {
1285             result.documentation = documentation;
1286         }
1287         if (Is.defined(parameters)) {
1288             result.parameters = parameters;
1289         }
1290         else {
1291             result.parameters = [];
1292         }
1293         return result;
1294     }
1295     SignatureInformation.create = create;
1296 })(SignatureInformation || (SignatureInformation = {}));
1297 /**
1298  * A document highlight kind.
1299  */
1300 export var DocumentHighlightKind;
1301 (function (DocumentHighlightKind) {
1302     /**
1303      * A textual occurrence.
1304      */
1305     DocumentHighlightKind.Text = 1;
1306     /**
1307      * Read-access of a symbol, like reading a variable.
1308      */
1309     DocumentHighlightKind.Read = 2;
1310     /**
1311      * Write-access of a symbol, like writing to a variable.
1312      */
1313     DocumentHighlightKind.Write = 3;
1314 })(DocumentHighlightKind || (DocumentHighlightKind = {}));
1315 /**
1316  * DocumentHighlight namespace to provide helper functions to work with
1317  * [DocumentHighlight](#DocumentHighlight) literals.
1318  */
1319 export var DocumentHighlight;
1320 (function (DocumentHighlight) {
1321     /**
1322      * Create a DocumentHighlight object.
1323      * @param range The range the highlight applies to.
1324      */
1325     function create(range, kind) {
1326         var result = { range: range };
1327         if (Is.number(kind)) {
1328             result.kind = kind;
1329         }
1330         return result;
1331     }
1332     DocumentHighlight.create = create;
1333 })(DocumentHighlight || (DocumentHighlight = {}));
1334 /**
1335  * A symbol kind.
1336  */
1337 export var SymbolKind;
1338 (function (SymbolKind) {
1339     SymbolKind.File = 1;
1340     SymbolKind.Module = 2;
1341     SymbolKind.Namespace = 3;
1342     SymbolKind.Package = 4;
1343     SymbolKind.Class = 5;
1344     SymbolKind.Method = 6;
1345     SymbolKind.Property = 7;
1346     SymbolKind.Field = 8;
1347     SymbolKind.Constructor = 9;
1348     SymbolKind.Enum = 10;
1349     SymbolKind.Interface = 11;
1350     SymbolKind.Function = 12;
1351     SymbolKind.Variable = 13;
1352     SymbolKind.Constant = 14;
1353     SymbolKind.String = 15;
1354     SymbolKind.Number = 16;
1355     SymbolKind.Boolean = 17;
1356     SymbolKind.Array = 18;
1357     SymbolKind.Object = 19;
1358     SymbolKind.Key = 20;
1359     SymbolKind.Null = 21;
1360     SymbolKind.EnumMember = 22;
1361     SymbolKind.Struct = 23;
1362     SymbolKind.Event = 24;
1363     SymbolKind.Operator = 25;
1364     SymbolKind.TypeParameter = 26;
1365 })(SymbolKind || (SymbolKind = {}));
1366 /**
1367  * Symbol tags are extra annotations that tweak the rendering of a symbol.
1368  * @since 3.16
1369  */
1370 export var SymbolTag;
1371 (function (SymbolTag) {
1372     /**
1373      * Render a symbol as obsolete, usually using a strike-out.
1374      */
1375     SymbolTag.Deprecated = 1;
1376 })(SymbolTag || (SymbolTag = {}));
1377 export var SymbolInformation;
1378 (function (SymbolInformation) {
1379     /**
1380      * Creates a new symbol information literal.
1381      *
1382      * @param name The name of the symbol.
1383      * @param kind The kind of the symbol.
1384      * @param range The range of the location of the symbol.
1385      * @param uri The resource of the location of symbol, defaults to the current document.
1386      * @param containerName The name of the symbol containing the symbol.
1387      */
1388     function create(name, kind, range, uri, containerName) {
1389         var result = {
1390             name: name,
1391             kind: kind,
1392             location: { uri: uri, range: range }
1393         };
1394         if (containerName) {
1395             result.containerName = containerName;
1396         }
1397         return result;
1398     }
1399     SymbolInformation.create = create;
1400 })(SymbolInformation || (SymbolInformation = {}));
1401 export var DocumentSymbol;
1402 (function (DocumentSymbol) {
1403     /**
1404      * Creates a new symbol information literal.
1405      *
1406      * @param name The name of the symbol.
1407      * @param detail The detail of the symbol.
1408      * @param kind The kind of the symbol.
1409      * @param range The range of the symbol.
1410      * @param selectionRange The selectionRange of the symbol.
1411      * @param children Children of the symbol.
1412      */
1413     function create(name, detail, kind, range, selectionRange, children) {
1414         var result = {
1415             name: name,
1416             detail: detail,
1417             kind: kind,
1418             range: range,
1419             selectionRange: selectionRange
1420         };
1421         if (children !== undefined) {
1422             result.children = children;
1423         }
1424         return result;
1425     }
1426     DocumentSymbol.create = create;
1427     /**
1428      * Checks whether the given literal conforms to the [DocumentSymbol](#DocumentSymbol) interface.
1429      */
1430     function is(value) {
1431         var candidate = value;
1432         return candidate &&
1433             Is.string(candidate.name) && Is.number(candidate.kind) &&
1434             Range.is(candidate.range) && Range.is(candidate.selectionRange) &&
1435             (candidate.detail === undefined || Is.string(candidate.detail)) &&
1436             (candidate.deprecated === undefined || Is.boolean(candidate.deprecated)) &&
1437             (candidate.children === undefined || Array.isArray(candidate.children)) &&
1438             (candidate.tags === undefined || Array.isArray(candidate.tags));
1439     }
1440     DocumentSymbol.is = is;
1441 })(DocumentSymbol || (DocumentSymbol = {}));
1442 /**
1443  * A set of predefined code action kinds
1444  */
1445 export var CodeActionKind;
1446 (function (CodeActionKind) {
1447     /**
1448      * Empty kind.
1449      */
1450     CodeActionKind.Empty = '';
1451     /**
1452      * Base kind for quickfix actions: 'quickfix'
1453      */
1454     CodeActionKind.QuickFix = 'quickfix';
1455     /**
1456      * Base kind for refactoring actions: 'refactor'
1457      */
1458     CodeActionKind.Refactor = 'refactor';
1459     /**
1460      * Base kind for refactoring extraction actions: 'refactor.extract'
1461      *
1462      * Example extract actions:
1463      *
1464      * - Extract method
1465      * - Extract function
1466      * - Extract variable
1467      * - Extract interface from class
1468      * - ...
1469      */
1470     CodeActionKind.RefactorExtract = 'refactor.extract';
1471     /**
1472      * Base kind for refactoring inline actions: 'refactor.inline'
1473      *
1474      * Example inline actions:
1475      *
1476      * - Inline function
1477      * - Inline variable
1478      * - Inline constant
1479      * - ...
1480      */
1481     CodeActionKind.RefactorInline = 'refactor.inline';
1482     /**
1483      * Base kind for refactoring rewrite actions: 'refactor.rewrite'
1484      *
1485      * Example rewrite actions:
1486      *
1487      * - Convert JavaScript function to class
1488      * - Add or remove parameter
1489      * - Encapsulate field
1490      * - Make method static
1491      * - Move method to base class
1492      * - ...
1493      */
1494     CodeActionKind.RefactorRewrite = 'refactor.rewrite';
1495     /**
1496      * Base kind for source actions: `source`
1497      *
1498      * Source code actions apply to the entire file.
1499      */
1500     CodeActionKind.Source = 'source';
1501     /**
1502      * Base kind for an organize imports source action: `source.organizeImports`
1503      */
1504     CodeActionKind.SourceOrganizeImports = 'source.organizeImports';
1505     /**
1506      * Base kind for auto-fix source actions: `source.fixAll`.
1507      *
1508      * Fix all actions automatically fix errors that have a clear fix that do not require user input.
1509      * They should not suppress errors or perform unsafe fixes such as generating new types or classes.
1510      *
1511      * @since 3.15.0
1512      */
1513     CodeActionKind.SourceFixAll = 'source.fixAll';
1514 })(CodeActionKind || (CodeActionKind = {}));
1515 /**
1516  * The CodeActionContext namespace provides helper functions to work with
1517  * [CodeActionContext](#CodeActionContext) literals.
1518  */
1519 export var CodeActionContext;
1520 (function (CodeActionContext) {
1521     /**
1522      * Creates a new CodeActionContext literal.
1523      */
1524     function create(diagnostics, only) {
1525         var result = { diagnostics: diagnostics };
1526         if (only !== undefined && only !== null) {
1527             result.only = only;
1528         }
1529         return result;
1530     }
1531     CodeActionContext.create = create;
1532     /**
1533      * Checks whether the given literal conforms to the [CodeActionContext](#CodeActionContext) interface.
1534      */
1535     function is(value) {
1536         var candidate = value;
1537         return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic.is) && (candidate.only === undefined || Is.typedArray(candidate.only, Is.string));
1538     }
1539     CodeActionContext.is = is;
1540 })(CodeActionContext || (CodeActionContext = {}));
1541 export var CodeAction;
1542 (function (CodeAction) {
1543     function create(title, kindOrCommandOrEdit, kind) {
1544         var result = { title: title };
1545         var checkKind = true;
1546         if (typeof kindOrCommandOrEdit === 'string') {
1547             checkKind = false;
1548             result.kind = kindOrCommandOrEdit;
1549         }
1550         else if (Command.is(kindOrCommandOrEdit)) {
1551             result.command = kindOrCommandOrEdit;
1552         }
1553         else {
1554             result.edit = kindOrCommandOrEdit;
1555         }
1556         if (checkKind && kind !== undefined) {
1557             result.kind = kind;
1558         }
1559         return result;
1560     }
1561     CodeAction.create = create;
1562     function is(value) {
1563         var candidate = value;
1564         return candidate && Is.string(candidate.title) &&
1565             (candidate.diagnostics === undefined || Is.typedArray(candidate.diagnostics, Diagnostic.is)) &&
1566             (candidate.kind === undefined || Is.string(candidate.kind)) &&
1567             (candidate.edit !== undefined || candidate.command !== undefined) &&
1568             (candidate.command === undefined || Command.is(candidate.command)) &&
1569             (candidate.isPreferred === undefined || Is.boolean(candidate.isPreferred)) &&
1570             (candidate.edit === undefined || WorkspaceEdit.is(candidate.edit));
1571     }
1572     CodeAction.is = is;
1573 })(CodeAction || (CodeAction = {}));
1574 /**
1575  * The CodeLens namespace provides helper functions to work with
1576  * [CodeLens](#CodeLens) literals.
1577  */
1578 export var CodeLens;
1579 (function (CodeLens) {
1580     /**
1581      * Creates a new CodeLens literal.
1582      */
1583     function create(range, data) {
1584         var result = { range: range };
1585         if (Is.defined(data)) {
1586             result.data = data;
1587         }
1588         return result;
1589     }
1590     CodeLens.create = create;
1591     /**
1592      * Checks whether the given literal conforms to the [CodeLens](#CodeLens) interface.
1593      */
1594     function is(value) {
1595         var candidate = value;
1596         return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
1597     }
1598     CodeLens.is = is;
1599 })(CodeLens || (CodeLens = {}));
1600 /**
1601  * The FormattingOptions namespace provides helper functions to work with
1602  * [FormattingOptions](#FormattingOptions) literals.
1603  */
1604 export var FormattingOptions;
1605 (function (FormattingOptions) {
1606     /**
1607      * Creates a new FormattingOptions literal.
1608      */
1609     function create(tabSize, insertSpaces) {
1610         return { tabSize: tabSize, insertSpaces: insertSpaces };
1611     }
1612     FormattingOptions.create = create;
1613     /**
1614      * Checks whether the given literal conforms to the [FormattingOptions](#FormattingOptions) interface.
1615      */
1616     function is(value) {
1617         var candidate = value;
1618         return Is.defined(candidate) && Is.uinteger(candidate.tabSize) && Is.boolean(candidate.insertSpaces);
1619     }
1620     FormattingOptions.is = is;
1621 })(FormattingOptions || (FormattingOptions = {}));
1622 /**
1623  * The DocumentLink namespace provides helper functions to work with
1624  * [DocumentLink](#DocumentLink) literals.
1625  */
1626 export var DocumentLink;
1627 (function (DocumentLink) {
1628     /**
1629      * Creates a new DocumentLink literal.
1630      */
1631     function create(range, target, data) {
1632         return { range: range, target: target, data: data };
1633     }
1634     DocumentLink.create = create;
1635     /**
1636      * Checks whether the given literal conforms to the [DocumentLink](#DocumentLink) interface.
1637      */
1638     function is(value) {
1639         var candidate = value;
1640         return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
1641     }
1642     DocumentLink.is = is;
1643 })(DocumentLink || (DocumentLink = {}));
1644 /**
1645  * The SelectionRange namespace provides helper function to work with
1646  * SelectionRange literals.
1647  */
1648 export var SelectionRange;
1649 (function (SelectionRange) {
1650     /**
1651      * Creates a new SelectionRange
1652      * @param range the range.
1653      * @param parent an optional parent.
1654      */
1655     function create(range, parent) {
1656         return { range: range, parent: parent };
1657     }
1658     SelectionRange.create = create;
1659     function is(value) {
1660         var candidate = value;
1661         return candidate !== undefined && Range.is(candidate.range) && (candidate.parent === undefined || SelectionRange.is(candidate.parent));
1662     }
1663     SelectionRange.is = is;
1664 })(SelectionRange || (SelectionRange = {}));
1665 export var EOL = ['\n', '\r\n', '\r'];
1666 /**
1667  * @deprecated Use the text document from the new vscode-languageserver-textdocument package.
1668  */
1669 export var TextDocument;
1670 (function (TextDocument) {
1671     /**
1672      * Creates a new ITextDocument literal from the given uri and content.
1673      * @param uri The document's uri.
1674      * @param languageId  The document's language Id.
1675      * @param content The document's content.
1676      */
1677     function create(uri, languageId, version, content) {
1678         return new FullTextDocument(uri, languageId, version, content);
1679     }
1680     TextDocument.create = create;
1681     /**
1682      * Checks whether the given literal conforms to the [ITextDocument](#ITextDocument) interface.
1683      */
1684     function is(value) {
1685         var candidate = value;
1686         return Is.defined(candidate) && Is.string(candidate.uri) && (Is.undefined(candidate.languageId) || Is.string(candidate.languageId)) && Is.uinteger(candidate.lineCount)
1687             && Is.func(candidate.getText) && Is.func(candidate.positionAt) && Is.func(candidate.offsetAt) ? true : false;
1688     }
1689     TextDocument.is = is;
1690     function applyEdits(document, edits) {
1691         var text = document.getText();
1692         var sortedEdits = mergeSort(edits, function (a, b) {
1693             var diff = a.range.start.line - b.range.start.line;
1694             if (diff === 0) {
1695                 return a.range.start.character - b.range.start.character;
1696             }
1697             return diff;
1698         });
1699         var lastModifiedOffset = text.length;
1700         for (var i = sortedEdits.length - 1; i >= 0; i--) {
1701             var e = sortedEdits[i];
1702             var startOffset = document.offsetAt(e.range.start);
1703             var endOffset = document.offsetAt(e.range.end);
1704             if (endOffset <= lastModifiedOffset) {
1705                 text = text.substring(0, startOffset) + e.newText + text.substring(endOffset, text.length);
1706             }
1707             else {
1708                 throw new Error('Overlapping edit');
1709             }
1710             lastModifiedOffset = startOffset;
1711         }
1712         return text;
1713     }
1714     TextDocument.applyEdits = applyEdits;
1715     function mergeSort(data, compare) {
1716         if (data.length <= 1) {
1717             // sorted
1718             return data;
1719         }
1720         var p = (data.length / 2) | 0;
1721         var left = data.slice(0, p);
1722         var right = data.slice(p);
1723         mergeSort(left, compare);
1724         mergeSort(right, compare);
1725         var leftIdx = 0;
1726         var rightIdx = 0;
1727         var i = 0;
1728         while (leftIdx < left.length && rightIdx < right.length) {
1729             var ret = compare(left[leftIdx], right[rightIdx]);
1730             if (ret <= 0) {
1731                 // smaller_equal -> take left to preserve order
1732                 data[i++] = left[leftIdx++];
1733             }
1734             else {
1735                 // greater -> take right
1736                 data[i++] = right[rightIdx++];
1737             }
1738         }
1739         while (leftIdx < left.length) {
1740             data[i++] = left[leftIdx++];
1741         }
1742         while (rightIdx < right.length) {
1743             data[i++] = right[rightIdx++];
1744         }
1745         return data;
1746     }
1747 })(TextDocument || (TextDocument = {}));
1748 /**
1749  * @deprecated Use the text document from the new vscode-languageserver-textdocument package.
1750  */
1751 var FullTextDocument = /** @class */ (function () {
1752     function FullTextDocument(uri, languageId, version, content) {
1753         this._uri = uri;
1754         this._languageId = languageId;
1755         this._version = version;
1756         this._content = content;
1757         this._lineOffsets = undefined;
1758     }
1759     Object.defineProperty(FullTextDocument.prototype, "uri", {
1760         get: function () {
1761             return this._uri;
1762         },
1763         enumerable: false,
1764         configurable: true
1765     });
1766     Object.defineProperty(FullTextDocument.prototype, "languageId", {
1767         get: function () {
1768             return this._languageId;
1769         },
1770         enumerable: false,
1771         configurable: true
1772     });
1773     Object.defineProperty(FullTextDocument.prototype, "version", {
1774         get: function () {
1775             return this._version;
1776         },
1777         enumerable: false,
1778         configurable: true
1779     });
1780     FullTextDocument.prototype.getText = function (range) {
1781         if (range) {
1782             var start = this.offsetAt(range.start);
1783             var end = this.offsetAt(range.end);
1784             return this._content.substring(start, end);
1785         }
1786         return this._content;
1787     };
1788     FullTextDocument.prototype.update = function (event, version) {
1789         this._content = event.text;
1790         this._version = version;
1791         this._lineOffsets = undefined;
1792     };
1793     FullTextDocument.prototype.getLineOffsets = function () {
1794         if (this._lineOffsets === undefined) {
1795             var lineOffsets = [];
1796             var text = this._content;
1797             var isLineStart = true;
1798             for (var i = 0; i < text.length; i++) {
1799                 if (isLineStart) {
1800                     lineOffsets.push(i);
1801                     isLineStart = false;
1802                 }
1803                 var ch = text.charAt(i);
1804                 isLineStart = (ch === '\r' || ch === '\n');
1805                 if (ch === '\r' && i + 1 < text.length && text.charAt(i + 1) === '\n') {
1806                     i++;
1807                 }
1808             }
1809             if (isLineStart && text.length > 0) {
1810                 lineOffsets.push(text.length);
1811             }
1812             this._lineOffsets = lineOffsets;
1813         }
1814         return this._lineOffsets;
1815     };
1816     FullTextDocument.prototype.positionAt = function (offset) {
1817         offset = Math.max(Math.min(offset, this._content.length), 0);
1818         var lineOffsets = this.getLineOffsets();
1819         var low = 0, high = lineOffsets.length;
1820         if (high === 0) {
1821             return Position.create(0, offset);
1822         }
1823         while (low < high) {
1824             var mid = Math.floor((low + high) / 2);
1825             if (lineOffsets[mid] > offset) {
1826                 high = mid;
1827             }
1828             else {
1829                 low = mid + 1;
1830             }
1831         }
1832         // low is the least x for which the line offset is larger than the current offset
1833         // or array.length if no line offset is larger than the current offset
1834         var line = low - 1;
1835         return Position.create(line, offset - lineOffsets[line]);
1836     };
1837     FullTextDocument.prototype.offsetAt = function (position) {
1838         var lineOffsets = this.getLineOffsets();
1839         if (position.line >= lineOffsets.length) {
1840             return this._content.length;
1841         }
1842         else if (position.line < 0) {
1843             return 0;
1844         }
1845         var lineOffset = lineOffsets[position.line];
1846         var nextLineOffset = (position.line + 1 < lineOffsets.length) ? lineOffsets[position.line + 1] : this._content.length;
1847         return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);
1848     };
1849     Object.defineProperty(FullTextDocument.prototype, "lineCount", {
1850         get: function () {
1851             return this.getLineOffsets().length;
1852         },
1853         enumerable: false,
1854         configurable: true
1855     });
1856     return FullTextDocument;
1857 }());
1858 var Is;
1859 (function (Is) {
1860     var toString = Object.prototype.toString;
1861     function defined(value) {
1862         return typeof value !== 'undefined';
1863     }
1864     Is.defined = defined;
1865     function undefined(value) {
1866         return typeof value === 'undefined';
1867     }
1868     Is.undefined = undefined;
1869     function boolean(value) {
1870         return value === true || value === false;
1871     }
1872     Is.boolean = boolean;
1873     function string(value) {
1874         return toString.call(value) === '[object String]';
1875     }
1876     Is.string = string;
1877     function number(value) {
1878         return toString.call(value) === '[object Number]';
1879     }
1880     Is.number = number;
1881     function numberRange(value, min, max) {
1882         return toString.call(value) === '[object Number]' && min <= value && value <= max;
1883     }
1884     Is.numberRange = numberRange;
1885     function integer(value) {
1886         return toString.call(value) === '[object Number]' && -2147483648 <= value && value <= 2147483647;
1887     }
1888     Is.integer = integer;
1889     function uinteger(value) {
1890         return toString.call(value) === '[object Number]' && 0 <= value && value <= 2147483647;
1891     }
1892     Is.uinteger = uinteger;
1893     function func(value) {
1894         return toString.call(value) === '[object Function]';
1895     }
1896     Is.func = func;
1897     function objectLiteral(value) {
1898         // Strictly speaking class instances pass this check as well. Since the LSP
1899         // doesn't use classes we ignore this for now. If we do we need to add something
1900         // like this: `Object.getPrototypeOf(Object.getPrototypeOf(x)) === null`
1901         return value !== null && typeof value === 'object';
1902     }
1903     Is.objectLiteral = objectLiteral;
1904     function typedArray(value, check) {
1905         return Array.isArray(value) && value.every(check);
1906     }
1907     Is.typedArray = typedArray;
1908 })(Is || (Is = {}));