-
Notifications
You must be signed in to change notification settings - Fork 105
/
Copy pathRangeOrPlaceholderRange.cs
64 lines (58 loc) · 1.76 KB
/
RangeOrPlaceholderRange.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using Newtonsoft.Json;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization.Converters;
namespace OmniSharp.Extensions.LanguageServer.Protocol.Models
{
[JsonConverter(typeof(RangeOrPlaceholderRangeConverter))]
public class RangeOrPlaceholderRange
{
private Range _range;
private PlaceholderRange _placeholderRange;
public RangeOrPlaceholderRange(Range value)
{
_range = value;
_placeholderRange = default;
}
public RangeOrPlaceholderRange(PlaceholderRange value)
{
_range = default;
_placeholderRange = value;
}
public bool IsPlaceholderRange => this._placeholderRange != null;
public PlaceholderRange PlaceholderRange
{
get { return this._placeholderRange; }
set
{
this._placeholderRange = value;
this._range = null;
}
}
public bool IsRange => this._range != null;
public Range Range
{
get { return this._range; }
set
{
this._placeholderRange = default;
this._range = value;
}
}
public object RawValue
{
get
{
if (IsPlaceholderRange) return PlaceholderRange;
if (IsRange) return Range;
return default;
}
}
public static implicit operator RangeOrPlaceholderRange(PlaceholderRange value)
{
return new RangeOrPlaceholderRange(value);
}
public static implicit operator RangeOrPlaceholderRange(Range value)
{
return new RangeOrPlaceholderRange(value);
}
}
}