Skip to content

Commit 4bb58af

Browse files
committed
Implement initialized notification handler to get rid of log error
We do nothing in the handler atm but in the future we can do dynamic registration of capabilities in it.
1 parent 8a1e9bd commit 4bb58af

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//
2+
// Copyright (c) Microsoft. All rights reserved.
3+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
4+
//
5+
6+
using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol;
7+
8+
namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer
9+
{
10+
/// <summary>
11+
/// The initialized notification is sent from the client to the server after the client received the result
12+
/// of the initialize request but before the client is sending any other request or notification to the server.
13+
/// The server can use the initialized notification for example to dynamically register capabilities.
14+
/// The initialized notification may only be sent once.
15+
/// </summary>
16+
public class InitializedNotification
17+
{
18+
public static readonly
19+
NotificationType<InitializedParams, object> Type =
20+
NotificationType<InitializedParams, object>.Create("initialized");
21+
}
22+
23+
/// <summary>
24+
/// Currently, the initialized message has no parameters.
25+
/// </summary>
26+
public class InitializedParams
27+
{
28+
}
29+
}

src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public void Start()
9999
this.messageHandlers.SetEventHandler(ExitNotification.Type, this.HandleExitNotification);
100100

101101
this.messageHandlers.SetRequestHandler(InitializeRequest.Type, this.HandleInitializeRequest);
102+
this.messageHandlers.SetEventHandler(InitializedNotification.Type, this.HandleInitializedNotification);
102103

103104
this.messageHandlers.SetEventHandler(DidOpenTextDocumentNotification.Type, this.HandleDidOpenTextDocumentNotification);
104105
this.messageHandlers.SetEventHandler(DidCloseTextDocumentNotification.Type, this.HandleDidCloseTextDocumentNotification);
@@ -178,6 +179,13 @@ private async Task HandleExitNotification(
178179
await this.Stop();
179180
}
180181

182+
private Task HandleInitializedNotification(InitializedParams initializedParams,
183+
EventContext eventContext)
184+
{
185+
// Can do dynamic registration of capabilities in this notification handler
186+
return Task.FromResult(true);
187+
}
188+
181189
protected async Task HandleInitializeRequest(
182190
InitializeParams initializeParams,
183191
RequestContext<InitializeResult> requestContext)

0 commit comments

Comments
 (0)