-
Notifications
You must be signed in to change notification settings - Fork 105
/
Copy pathCommandOrCodeAction.cs
66 lines (60 loc) · 1.95 KB
/
CommandOrCodeAction.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
65
66
using System.Diagnostics;
using Newtonsoft.Json;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization.Converters;
namespace OmniSharp.Extensions.LanguageServer.Protocol.Models
{
[JsonConverter(typeof(CommandOrCodeActionConverter))]
[DebuggerDisplay("{" + nameof(DebuggerDisplay) + ",nq}")]
public struct CommandOrCodeAction
{
private CodeAction _codeAction;
private Command _command;
public CommandOrCodeAction(CodeAction value)
{
_codeAction = value;
_command = default;
}
public CommandOrCodeAction(Command value)
{
_codeAction = default;
_command = value;
}
public bool IsCommand => this._command != null;
public Command Command
{
get { return this._command; }
set {
this._command = value;
this._codeAction = null;
}
}
public bool IsCodeAction => this._codeAction != null;
public CodeAction CodeAction
{
get { return this._codeAction; }
set {
this._command = default;
this._codeAction = value;
}
}
public object RawValue
{
get {
if (IsCommand) return Command;
if (IsCodeAction) return CodeAction;
return default;
}
}
public static implicit operator CommandOrCodeAction(Command value)
{
return new CommandOrCodeAction(value);
}
public static implicit operator CommandOrCodeAction(CodeAction value)
{
return new CommandOrCodeAction(value);
}
private string DebuggerDisplay => $"{(IsCommand ? $"command: {Command}" : IsCodeAction ? $"code action: {CodeAction}" : "...")}";
/// <inheritdoc />
public override string ToString() => DebuggerDisplay;
}
}