4
4
using System . Threading . Tasks ;
5
5
using System . Management . Automation . Language ;
6
6
7
- namespace System . Management . Automation . Subsystem
7
+ namespace System . Management . Automation . Subsystem . Prediction
8
8
{
9
+ /// <summary>
10
+ /// Kinds of prediction clients.
11
+ /// </summary>
12
+ public enum PredictionClientKind
13
+ {
14
+ /// <summary>
15
+ /// A terminal client, representing the command-line experience.
16
+ /// </summary>
17
+ Terminal ,
18
+
19
+ /// <summary>
20
+ /// An editor client, representing the editor experience.
21
+ /// </summary>
22
+ Editor ,
23
+ }
24
+
25
+ /// <summary>
26
+ /// The class represents a client that interacts with predictors.
27
+ /// </summary>
28
+ public sealed class PredictionClient
29
+ {
30
+ /// <summary>
31
+ /// Gets the client name.
32
+ /// </summary>
33
+ [ HiddenAttribute ]
34
+ public string Name { get ; }
35
+
36
+ /// <summary>
37
+ /// Gets the client kind.
38
+ /// </summary>
39
+ [ HiddenAttribute ]
40
+ public PredictionClientKind Kind { get ; }
41
+
42
+ /// <summary>
43
+ /// Initializes a new instance of the <see cref="PredictionClient"/> class.
44
+ /// </summary>
45
+ /// <param name="name">Name of the interactive client.</param>
46
+ /// <param name="kind">Kind of the interactive client.</param>
47
+ [ HiddenAttribute ]
48
+ public PredictionClient ( string name , PredictionClientKind kind )
49
+ {
50
+ Name = name ;
51
+ Kind = kind ;
52
+ }
53
+ }
54
+
9
55
/// <summary>
10
56
/// The class represents the prediction result from a predictor.
11
57
/// </summary>
@@ -103,7 +149,7 @@ public static class CommandPrediction
103
149
/// <param name="astTokens">The <see cref="Token"/> objects from parsing the current command line input.</param>
104
150
/// <returns>A list of <see cref="PredictionResult"/> objects.</returns>
105
151
[ HiddenAttribute ]
106
- public static Task < List < PredictionResult > > PredictInput ( string client , Ast ast , Token [ ] astTokens )
152
+ public static Task < List < PredictionResult > > PredictInputAsync ( PredictionClient client , Ast ast , Token [ ] astTokens )
107
153
{
108
154
return null ;
109
155
}
@@ -117,7 +163,7 @@ public static Task<List<PredictionResult>> PredictInput(string client, Ast ast,
117
163
/// <param name="millisecondsTimeout">The milliseconds to timeout.</param>
118
164
/// <returns>A list of <see cref="PredictionResult"/> objects.</returns>
119
165
[ HiddenAttribute ]
120
- public static Task < List < PredictionResult > > PredictInput ( string client , Ast ast , Token [ ] astTokens , int millisecondsTimeout )
166
+ public static Task < List < PredictionResult > > PredictInputAsync ( PredictionClient client , Ast ast , Token [ ] astTokens , int millisecondsTimeout )
121
167
{
122
168
return null ;
123
169
}
@@ -128,7 +174,18 @@ public static Task<List<PredictionResult>> PredictInput(string client, Ast ast,
128
174
/// <param name="client">Represents the client that initiates the call.</param>
129
175
/// <param name="history">History command lines provided as references for prediction.</param>
130
176
[ HiddenAttribute ]
131
- public static void OnCommandLineAccepted ( string client , IReadOnlyList < string > history )
177
+ public static void OnCommandLineAccepted ( PredictionClient client , IReadOnlyList < string > history )
178
+ {
179
+ }
180
+
181
+ /// <summary>
182
+ /// Allow registered predictors to know the execution result (success/failure) of the last accepted command line.
183
+ /// </summary>
184
+ /// <param name="client">Represents the client that initiates the call.</param>
185
+ /// <param name="commandLine">The last accepted command line.</param>
186
+ /// <param name="success">Whether the execution of the last command line was successful.</param>
187
+ [ HiddenAttribute ]
188
+ public static void OnCommandLineExecuted ( PredictionClient client , string commandLine , bool success )
132
189
{
133
190
}
134
191
@@ -143,7 +200,7 @@ public static void OnCommandLineAccepted(string client, IReadOnlyList<string> hi
143
200
/// When the value is <code><= 0</code>, it means a single suggestion from the list got displayed, and the index is the absolute value.
144
201
/// </param>
145
202
[ HiddenAttribute ]
146
- public static void OnSuggestionDisplayed ( string client , Guid predictorId , uint session , int countOrIndex )
203
+ public static void OnSuggestionDisplayed ( PredictionClient client , Guid predictorId , uint session , int countOrIndex )
147
204
{
148
205
}
149
206
@@ -155,17 +212,19 @@ public static void OnSuggestionDisplayed(string client, Guid predictorId, uint s
155
212
/// <param name="session">The mini-session where the accepted suggestion came from.</param>
156
213
/// <param name="suggestionText">The accepted suggestion text.</param>
157
214
[ HiddenAttribute ]
158
- public static void OnSuggestionAccepted ( string client , Guid predictorId , uint session , string suggestionText )
215
+ public static void OnSuggestionAccepted ( PredictionClient client , Guid predictorId , uint session , string suggestionText )
159
216
{
160
217
}
161
218
}
162
219
}
163
220
164
221
#else
165
222
166
- using System . Management . Automation . Subsystem ;
223
+ using System . Management . Automation . Subsystem . Prediction ;
167
224
using System . Runtime . CompilerServices ;
168
225
226
+ [ assembly: TypeForwardedTo ( typeof ( PredictionClientKind ) ) ]
227
+ [ assembly: TypeForwardedTo ( typeof ( PredictionClient ) ) ]
169
228
[ assembly: TypeForwardedTo ( typeof ( PredictiveSuggestion ) ) ]
170
229
[ assembly: TypeForwardedTo ( typeof ( PredictionResult ) ) ]
171
230
[ assembly: TypeForwardedTo ( typeof ( CommandPrediction ) ) ]
0 commit comments