From 41612128377ade94296e50ebd6a89418a356fd0b Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Mon, 12 Mar 2018 15:42:50 -0700 Subject: [PATCH 1/2] Add events for PowerShell execution status (running, completed, etc). Create notification events for when the Language Server runs PowerShell scripts, so the client is informed about the status of the running script. --- .../ExecutionStatusChangedEvent.cs | 18 ++++++++++++++++++ .../Server/LanguageServer.cs | 15 +++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/PowerShellEditorServices.Protocol/LanguageServer/ExecutionStatusChangedEvent.cs diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/ExecutionStatusChangedEvent.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/ExecutionStatusChangedEvent.cs new file mode 100644 index 000000000..590683608 --- /dev/null +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/ExecutionStatusChangedEvent.cs @@ -0,0 +1,18 @@ +using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol; + +namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer +{ + /// + /// Defines an event type for PowerShell context execution status changes (e.g. execution has completed) + /// + public class ExecutionStatusChangedEvent + { + /// + /// The notification type for execution status change events in the message protocol + /// + /// + public static readonly + NotificationType Type = + NotificationType.Create("powerShell/executionStatusChanged"); + } +} diff --git a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs index 854812717..581728b45 100644 --- a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs +++ b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs @@ -56,7 +56,9 @@ public LanguageServer( { this.Logger = logger; this.editorSession = editorSession; + // Attach to the underlying PowerShell context to listen for changes in the runspace or execution status this.editorSession.PowerShellContext.RunspaceChanged += PowerShellContext_RunspaceChanged; + this.editorSession.PowerShellContext.ExecutionStatusChanged += PowerShellContext_ExecutionStatusChanged; // Attach to ExtensionService events this.editorSession.ExtensionService.CommandAdded += ExtensionService_ExtensionAdded; @@ -1273,6 +1275,19 @@ await this.messageSender.SendEvent( new Protocol.LanguageServer.RunspaceDetails(e.NewRunspace)); } + /// + /// Event hook on the PowerShell context to listen for changes in script execution status + /// + /// the PowerShell context sending the execution event + /// details of the execution status change + /// + private async void PowerShellContext_ExecutionStatusChanged(object sender, ExecutionStatusChangedEventArgs e) + { + await this.messageSender.SendEvent( + ExecutionStatusChangedEvent.Type, + e); + } + private async void ExtensionService_ExtensionAdded(object sender, EditorCommand e) { await this.messageSender.SendEvent( From d3bc268bd71c58b4ca3580a40be1f9aaf68aa361 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Thu, 15 Mar 2018 16:17:20 -0700 Subject: [PATCH 2/2] Remove empty doc-comments --- .../LanguageServer/ExecutionStatusChangedEvent.cs | 1 - src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs | 1 - 2 files changed, 2 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/ExecutionStatusChangedEvent.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/ExecutionStatusChangedEvent.cs index 590683608..5ac6eac6d 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/ExecutionStatusChangedEvent.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/ExecutionStatusChangedEvent.cs @@ -10,7 +10,6 @@ public class ExecutionStatusChangedEvent /// /// The notification type for execution status change events in the message protocol /// - /// public static readonly NotificationType Type = NotificationType.Create("powerShell/executionStatusChanged"); diff --git a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs index 581728b45..f551d4884 100644 --- a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs +++ b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs @@ -1280,7 +1280,6 @@ await this.messageSender.SendEvent( /// /// the PowerShell context sending the execution event /// details of the execution status change - /// private async void PowerShellContext_ExecutionStatusChanged(object sender, ExecutionStatusChangedEventArgs e) { await this.messageSender.SendEvent(