Skip to content

Implement initialized notification handler to get rid of log error #674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// 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.
/// </summary>
public class InitializedNotification
{
public static readonly
NotificationType<InitializedParams, object> Type =
NotificationType<InitializedParams, object>.Create("initialized");
}

/// <summary>
/// Currently, the initialized message has no parameters.
/// </summary>
public class InitializedParams
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<InitializeResult> requestContext)
Expand Down