|
| 1 | +using LanguageServer.Json; |
| 2 | + |
| 3 | +namespace LanguageServer.Parameters.General |
| 4 | +{ |
| 5 | + /// <summary> |
| 6 | + /// For <c>initialize</c> |
| 7 | + /// </summary> |
| 8 | + /// <remarks> |
| 9 | + /// The original spec describes the union type of |
| 10 | + /// <c>boolean</c>, <c>FoldingRangeProviderOptions</c>, or the intersection type |
| 11 | + /// <c>(FoldingRangeProviderOptions & TextDocumentRegistrationOptions & StaticRegistrationOptions)</c>. |
| 12 | + /// This implementation defines <see cref="FoldingRangeProviderOptions"/> class instead of the intersection type. |
| 13 | + /// </remarks> |
| 14 | + /// <seealso>Spec 3.10.0</seealso> |
| 15 | + public class FoldingRangeProviderOptionsOrBoolean : Either |
| 16 | + { |
| 17 | + /// <summary> |
| 18 | + /// Defines an implicit conversion of a <see cref="FoldingRangeProviderOptions"/> to a <see cref="FoldingRangeProviderOptionsOrBoolean"/> |
| 19 | + /// </summary> |
| 20 | + /// <param name="value"></param> |
| 21 | + /// <returns></returns> |
| 22 | + public static implicit operator FoldingRangeProviderOptionsOrBoolean(FoldingRangeProviderOptions value) |
| 23 | + => new FoldingRangeProviderOptionsOrBoolean(value); |
| 24 | + |
| 25 | + /// <summary> |
| 26 | + /// Defines an implicit conversion of a <see cref="bool"/> to a <see cref="FoldingRangeProviderOptionsOrBoolean"/> |
| 27 | + /// </summary> |
| 28 | + /// <param name="value"></param> |
| 29 | + /// <returns></returns> |
| 30 | + public static implicit operator FoldingRangeProviderOptionsOrBoolean(bool value) |
| 31 | + => new FoldingRangeProviderOptionsOrBoolean(value); |
| 32 | + |
| 33 | + /// <summary> |
| 34 | + /// Initializes a new instance of <c>FoldingRangeProviderOptionsOrBoolean</c> with the specified value. |
| 35 | + /// </summary> |
| 36 | + /// <param name="value"></param> |
| 37 | + public FoldingRangeProviderOptionsOrBoolean(FoldingRangeProviderOptions value) |
| 38 | + { |
| 39 | + Type = typeof(FoldingRangeProviderOptions); |
| 40 | + Value = value; |
| 41 | + } |
| 42 | + |
| 43 | + /// <summary> |
| 44 | + /// Initializes a new instance of <c>FoldingRangeProviderOptionsOrBoolean</c> with the specified value. |
| 45 | + /// </summary> |
| 46 | + /// <param name="value"></param> |
| 47 | + public FoldingRangeProviderOptionsOrBoolean(bool value) |
| 48 | + { |
| 49 | + Type = typeof(bool); |
| 50 | + Value = value; |
| 51 | + } |
| 52 | + |
| 53 | + /// <summary> |
| 54 | + /// Returns true if its underlying value is a <see cref="FoldingRangeProviderOptions"/>. |
| 55 | + /// </summary> |
| 56 | + public bool IsFoldingRangeProviderOptions => Type == typeof(FoldingRangeProviderOptions); |
| 57 | + |
| 58 | + /// <summary> |
| 59 | + /// Returns true if its underlying value is a <see cref="bool"/>. |
| 60 | + /// </summary> |
| 61 | + public bool IsBoolean => Type == typeof(bool); |
| 62 | + |
| 63 | + /// <summary> |
| 64 | + /// Gets the value of the current object if its underlying value is a <see cref="FoldingRangeProviderOptions"/>. |
| 65 | + /// </summary> |
| 66 | + public FoldingRangeProviderOptions FoldingRangeProviderOptions => GetValue<FoldingRangeProviderOptions>(); |
| 67 | + |
| 68 | + /// <summary> |
| 69 | + /// Gets the value of the current object if its underlying value is a <see cref="bool"/>. |
| 70 | + /// </summary> |
| 71 | + public bool Boolean => GetValue<bool>(); |
| 72 | + } |
| 73 | +} |
0 commit comments