diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/InitializedNotification.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/InitializedNotification.cs new file mode 100644 index 000000000..90836017f --- /dev/null +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/InitializedNotification.cs @@ -0,0 +1,29 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol; + +namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer +{ + /// + /// The initialized notification is sent from the client to the server after the client received the result + /// of the initialize request but before the client is sending any other request or notification to the server. + /// The server can use the initialized notification for example to dynamically register capabilities. + /// The initialized notification may only be sent once. + /// + public class InitializedNotification + { + public static readonly + NotificationType Type = + NotificationType.Create("initialized"); + } + + /// + /// Currently, the initialized message has no parameters. + /// + public class InitializedParams + { + } +} diff --git a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs index 57fb6b557..eafe34fdb 100644 --- a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs +++ b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs @@ -99,6 +99,7 @@ public void Start() this.messageHandlers.SetEventHandler(ExitNotification.Type, this.HandleExitNotification); this.messageHandlers.SetRequestHandler(InitializeRequest.Type, this.HandleInitializeRequest); + this.messageHandlers.SetEventHandler(InitializedNotification.Type, this.HandleInitializedNotification); this.messageHandlers.SetEventHandler(DidOpenTextDocumentNotification.Type, this.HandleDidOpenTextDocumentNotification); this.messageHandlers.SetEventHandler(DidCloseTextDocumentNotification.Type, this.HandleDidCloseTextDocumentNotification); @@ -178,6 +179,13 @@ private async Task HandleExitNotification( await this.Stop(); } + private Task HandleInitializedNotification(InitializedParams initializedParams, + EventContext eventContext) + { + // Can do dynamic registration of capabilities in this notification handler + return Task.FromResult(true); + } + protected async Task HandleInitializeRequest( InitializeParams initializeParams, RequestContext requestContext)