Skip to content

Commit 66c6485

Browse files
Kapil Borledaviwil
Kapil Borle
authored andcommitted
Add RequestType0 type and update related code
1 parent de6a788 commit 66c6485

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

src/PowerShellEditorServices.Protocol/LanguageServer/Shutdown.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer
1414
public class ShutdownRequest
1515
{
1616
public static readonly
17-
RequestType<object, object> Type =
18-
RequestType<object, object>.Create("shutdown");
17+
RequestType0<object, object, object> Type =
18+
RequestType0<object, object, object>.Create("shutdown");
1919
}
2020

2121
/// <summary>

src/PowerShellEditorServices.Protocol/MessageProtocol/ProtocolEndpoint.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,15 @@ public async Task Stop()
132132

133133
#region Message Sending
134134

135+
public Task<TResult> SendRequest<TResult, TError, TRegistrationOption>(
136+
RequestType0<TResult, TError, TRegistrationOption> requestType0)
137+
{
138+
return this.SendRequest<Object, TResult>(
139+
RequestType<Object, TResult>.ConvertToReqestType(requestType0),
140+
null);
141+
}
142+
143+
135144
/// <summary>
136145
/// Sends a request to the server
137146
/// </summary>
@@ -254,6 +263,18 @@ await this.protocolChannel.MessageWriter.WriteEvent(
254263

255264
#region Message Handling
256265

266+
public void SetRequestHandler<TResult, TError, TRegistrationOption>(
267+
RequestType0<TResult, TError, TRegistrationOption> requestType0,
268+
Func<RequestContext<TResult>, Task> requestHandler)
269+
{
270+
SetRequestHandler(
271+
RequestType<Object, TResult>.ConvertToReqestType(requestType0),
272+
(param1, requestContext) =>
273+
{
274+
return requestHandler(requestContext);
275+
});
276+
}
277+
257278
public void SetRequestHandler<TParams, TResult>(
258279
RequestType<TParams, TResult> requestType,
259280
Func<TParams, RequestContext<TResult>, Task> requestHandler)

src/PowerShellEditorServices.Protocol/MessageProtocol/RequestType.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,18 @@ public class RequestType<TParams, TResult>
1212
{
1313
public string MethodName { get; private set; }
1414

15+
public static RequestType<TParams, TResult> ConvertToReqestType<TError, TRegistrationOption>(
16+
RequestType0<TResult, TError, TRegistrationOption> requestType0)
17+
{
18+
return RequestType<TParams, TResult>.Create(requestType0.Method);
19+
}
1520
public static RequestType<TParams, TResult> Create(string typeName)
1621
{
22+
if (typeName == null)
23+
{
24+
throw new System.ArgumentNullException(nameof(typeName));
25+
}
26+
1727
return new RequestType<TParams, TResult>()
1828
{
1929
MethodName = typeName

src/PowerShellEditorServices.Protocol/Server/LanguageServerBase.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ protected virtual Task Shutdown()
5555
}
5656

5757
private async Task HandleShutdownRequest(
58-
object shutdownParams,
5958
RequestContext<object> requestContext)
6059
{
6160
// Allow the implementor to shut down gracefully

0 commit comments

Comments
 (0)