-
Notifications
You must be signed in to change notification settings - Fork 105
/
Copy pathSymbolInformationOrDocumentSymbol.cs
54 lines (46 loc) · 2 KB
/
SymbolInformationOrDocumentSymbol.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
using System.Diagnostics;
using Newtonsoft.Json;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization.Converters;
namespace OmniSharp.Extensions.LanguageServer.Protocol.Models
{
[JsonConverter(typeof(SymbolInformationOrDocumentSymbolConverter))]
[DebuggerDisplay("{" + nameof(DebuggerDisplay) + ",nq}")]
public struct SymbolInformationOrDocumentSymbol
{
private DocumentSymbol _documentSymbol;
private SymbolInformation _symbolInformation;
public SymbolInformationOrDocumentSymbol(DocumentSymbol documentSymbol)
{
_documentSymbol = documentSymbol;
_symbolInformation = default;
}
public SymbolInformationOrDocumentSymbol(SymbolInformation symbolInformation)
{
_documentSymbol = default;
_symbolInformation = symbolInformation;
}
public bool IsDocumentSymbolInformation => _symbolInformation != null;
public SymbolInformation SymbolInformation => _symbolInformation;
public bool IsDocumentSymbol => _documentSymbol != null;
public DocumentSymbol DocumentSymbol => _documentSymbol;
public static SymbolInformationOrDocumentSymbol Create(SymbolInformation value)
{
return value;
}
public static SymbolInformationOrDocumentSymbol Create(DocumentSymbol value)
{
return value;
}
public static implicit operator SymbolInformationOrDocumentSymbol(SymbolInformation value)
{
return new SymbolInformationOrDocumentSymbol(value);
}
public static implicit operator SymbolInformationOrDocumentSymbol(DocumentSymbol value)
{
return new SymbolInformationOrDocumentSymbol(value);
}
private string DebuggerDisplay => IsDocumentSymbol ? DocumentSymbol.ToString() : IsDocumentSymbolInformation ? SymbolInformation.ToString() : string.Empty;
/// <inheritdoc />
public override string ToString() => DebuggerDisplay;
}
}