44using System . Threading . Tasks ;
55using System . Management . Automation . Language ;
66
7- namespace System . Management . Automation . Subsystem
7+ namespace System . Management . Automation . Subsystem . Prediction
88{
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+
955 /// <summary>
1056 /// The class represents the prediction result from a predictor.
1157 /// </summary>
@@ -103,7 +149,7 @@ public static class CommandPrediction
103149 /// <param name="astTokens">The <see cref="Token"/> objects from parsing the current command line input.</param>
104150 /// <returns>A list of <see cref="PredictionResult"/> objects.</returns>
105151 [ 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 )
107153 {
108154 return null ;
109155 }
@@ -117,7 +163,7 @@ public static Task<List<PredictionResult>> PredictInput(string client, Ast ast,
117163 /// <param name="millisecondsTimeout">The milliseconds to timeout.</param>
118164 /// <returns>A list of <see cref="PredictionResult"/> objects.</returns>
119165 [ 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 )
121167 {
122168 return null ;
123169 }
@@ -128,7 +174,18 @@ public static Task<List<PredictionResult>> PredictInput(string client, Ast ast,
128174 /// <param name="client">Represents the client that initiates the call.</param>
129175 /// <param name="history">History command lines provided as references for prediction.</param>
130176 [ 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 )
132189 {
133190 }
134191
@@ -143,7 +200,7 @@ public static void OnCommandLineAccepted(string client, IReadOnlyList<string> hi
143200 /// When the value is <code><= 0</code>, it means a single suggestion from the list got displayed, and the index is the absolute value.
144201 /// </param>
145202 [ 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 )
147204 {
148205 }
149206
@@ -155,17 +212,19 @@ public static void OnSuggestionDisplayed(string client, Guid predictorId, uint s
155212 /// <param name="session">The mini-session where the accepted suggestion came from.</param>
156213 /// <param name="suggestionText">The accepted suggestion text.</param>
157214 [ 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 )
159216 {
160217 }
161218 }
162219}
163220
164221#else
165222
166- using System . Management . Automation . Subsystem ;
223+ using System . Management . Automation . Subsystem . Prediction ;
167224using System . Runtime . CompilerServices ;
168225
226+ [ assembly: TypeForwardedTo ( typeof ( PredictionClientKind ) ) ]
227+ [ assembly: TypeForwardedTo ( typeof ( PredictionClient ) ) ]
169228[ assembly: TypeForwardedTo ( typeof ( PredictiveSuggestion ) ) ]
170229[ assembly: TypeForwardedTo ( typeof ( PredictionResult ) ) ]
171230[ assembly: TypeForwardedTo ( typeof ( CommandPrediction ) ) ]
0 commit comments