/
SuggestedActionBase.cs
126 lines (108 loc) · 3.02 KB
/
SuggestedActionBase.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
using Microsoft.VisualStudio.Imaging.Interop;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace MadsKristensen.EditorExtensions.Html
{
/// <summary>
/// Base class for suggested action implementations. Actions can derive from this type and specialize as necessary for their appropriate
/// language context (e.g. HTML, JSON, etc).
/// </summary>
public abstract class SuggestedActionBase : ISuggestedAction
{
public SuggestedActionBase(ITextBuffer buffer, ITextView view, string displayText)
{
TextBuffer = buffer;
TextView = view;
DisplayText = displayText;
}
public ITextBuffer TextBuffer
{
get;
private set;
}
public ITextView TextView
{
get;
private set;
}
#region ISuggestedAction members
/// <summary>
/// By default, nested actions are not supported.
/// </summary>
public virtual bool HasActionSets
{
get
{
return false;
}
}
/// <summary>
/// By default, nested actions are not supported.
/// </summary>
public virtual Task<IEnumerable<SuggestedActionSet>> GetActionSetsAsync(CancellationToken cancellationToken)
{
return Task.FromResult<IEnumerable<SuggestedActionSet>>(null);
}
public string DisplayText
{
get;
private set;
}
public string IconAutomationText
{
get;
protected set;
}
public ImageMoniker IconMoniker
{
get;
protected set;
}
public string InputGestureText
{
get;
protected set;
}
/// <summary>
/// By default, Preview is not supported.
/// </summary>
public virtual bool HasPreview
{
get
{
return false;
}
}
/// <summary>
/// By default, Preview is not supported.
/// </summary>
public virtual Task<object> GetPreviewAsync(CancellationToken cancellationToken)
{
return Task.FromResult<object>(null);
}
public abstract void Invoke(CancellationToken cancellationToken);
/// <summary>
/// By default, telemetry is not supported.
/// </summary>
public virtual bool TryGetTelemetryId(out Guid telemetryId)
{
telemetryId = Guid.Empty;
return false;
}
#region IDisposable Support
protected virtual void Dispose(bool disposing)
{
}
public void Dispose()
{
Dispose(true);
}
#endregion
#endregion
}
}